This topic is locked
[SOLVED]

 Highlighting searched words in result list

1/4/2010 12:56:40 PM
PHPRunner General questions
D
Dale author

Best for the new year to all.
In version 3 of phprunner, there was a code snippet in a ( I forget what exact file ) file, that when you used the search on a list, it would highlight in yellow, any words in the resulting list that matched the search criteria. It was only in the search, not the advanced search, although that would have been a nice function to have also.
In the 5.1 is there a way to handle this or can you tell me what I need to add to make this happen.

D
Dale author 1/5/2010

Bump.

R
Rigmantas 1/6/2010

Hi,

In Visual Editor, View as, Custom:
$find[0]=$_REQUEST["SearchFor"];

$find[1]=ucwords($_REQUEST["SearchFor"]);

$find[2]=strtolower($_REQUEST["SearchFor"]);

$find[3]=strtoupper($_REQUEST["SearchFor"]);

$replace[0]="<span style=\"background-color: #ffff00\">".$find[0]."</span>";

$replace[1]="<span style=\"background-color: #ffff00\">".$find[1]."</span>";

$replace[2]="<span style=\"background-color: #ffff00\">".$find[2]."</span>";

$replace[3]="<span style=\"background-color: #ffff00\">".$find[3]."</span>";

$value = str_replace($find, $replace, $value);
For advanced search:
$find[4]=$_REQUEST["value_pavarde"];

$find[5]=ucwords($_REQUEST["value_pavarde"]);

$find[6]=strtolower($_REQUEST["value_pavarde"]);

$find[7]=strtoupper($_REQUEST["value_pavarde"]);
$find[9]=$_REQUEST["value_vardas"];

$find[10]=ucwords($_REQUEST["value_vardas"]);

$find[11]=strtolower($_REQUEST["value_vardas"]);

$find[12]=strtoupper($_REQUEST["value_vardas"]);
$replace[4]="<span style=\"background-color: #ffff00\">".$find[4]."</span>";

$replace[5]="<span style=\"background-color: #ffff00\">".$find[5]."</span>";

$replace[6]="<span style=\"background-color: #ffff00\">".$find[6]."</span>";

$replace[7]="<span style=\"background-color: #ffff00\">".$find[7]."</span>";
$replace[9]="<span style=\"background-color: #ffff00\">".$find[9]."</span>";

$replace[10]="<span style=\"background-color: #ffff00\">".$find[10]."</span>";

$replace[11]="<span style=\"background-color: #ffff00\">".$find[11]."</span>";

$replace[12]="<span style=\"background-color: #ffff00\">".$find[12]."</span>";

$value = str_replace($find, $replace, $value);

D
Dale author 1/6/2010

Thanks for the info.

Not exactly sure where to paste this but I will play with it.

Also not sure what "value_pavarde" is, but I will look at the advance search submits.
Im sure I will figure it all out. Thanks again for the tip.

J
Jane 1/7/2010

Dale,
open generated include/commonfunctions.php file, locate ProcessLargeText function, find and uncomment 'highlight search results' section.

R
Rigmantas 1/7/2010

HI

value_pavarde this is my value. You must change it to your value. This script also work in values when you use in html mode (about Jane example in html mode this not work). What i am do: in values properties/view as/custom i write my script, then ok and save the project. When i again open value properties an select view as HTML ok and again save project and this work for me.

Rimantas

D
Dale author 1/7/2010

Perfect thanks Jane.
Thanks also to Rimantas, I know it takes time to read and reply to help out. I really appreciate yours and everyone, who can help others out.

I respond to some myself, but I find the answers and responses from Jane, Sergey and their support team are fantastic. Koodo's to all.