This topic is locked

alter default choice for date field in Advanced search

2/11/2007 10:36:38 AM
PHPRunner General questions
T
thesofa author

my users have to filter the data using the Between choice in date fields, it would be lovely if I could always offer this as the default choice for them.

I have read read the post here about altering the generated files.

I have seen a post on here about altering the source files so if a field on the advanced search page is a date field, the default selection is "Between".

I cannot find it, and it was probably for version 3.0 as I recall using it for one project.

Is it possible to alter the source files for version 3.1 build 212 to change the date field default choice to be "Between" please?

Thanks for all the help, still a fantastic product and getting better.

J
Jane 2/12/2007

Hi,
open generated ..._search.php file, find following line:

if($not)

$smarty->assign("not_number"," checked");

// write search options

and edit code snippet just after. See my changes in Bold:

$options="";

$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">"."Between"."</option>";

$options.="<OPTION VALUE=\"Contains\" ".(($opt=="Contains")?"selected":"").">"."Contains"."</option>";

$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">"."Equals"."</option>";

$options.="<OPTION VALUE=\"Starts with ...\" ".(($opt=="Starts with ...")?"selected":"").">"."Starts with ..."."</option>";

$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">"."More than ..."."</option>";

$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">"."Less than ..."."</option>";

$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">"."Equal or more than ..."."</option>";

$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">"."Equal or less than ..."."</option>";

$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">"."Empty"."</option>";

T
thesofa author 2/12/2007

Thank you for the quick as ever reply.

As I would like all the date fields to have a default search Option of "Between" is there a way I can alter this in the source code to save having to make the changes after each maintenance build?

J
Jane 2/13/2007

Sure. Open C:/Program Files/PHPRunner3.2/source/search.php file, find and edit following code:

##if @f.strEditFormat==EDIT_FORMAT_DATE##

$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">".##message EQUALS##."</option>";

$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">".##message MORE_THAN##."</option>";

$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">".##message LESS_THAN##."</option>";

$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">".##message EQUAL_OR_MORE##."</option>";

$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">".##message EQUAL_OR_LESS##."</option>";

$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">".##message BETWEEN##."</option>";

$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">".##message EMPTY##."</option>";