This topic is locked

Search result highlighting

11/22/2012 9:52:14 AM
PHPRunner General questions
K
kleboe author

Hi there,
I am trying to find a way to highlight text on the list page that matches to the text I type in the search box. So for example, if I type 'name' in the search box, any instance of 'name' will highlight (in yellow) in all the records on the current list page.
I have tried going into the include/commonfunctions.php file and uncommenting the section of code to enable search keyword highlighting, however nothing happens. I have also tried pasting the following section of code into the view-as custom code properties of each of my fields, however nothing happens.
$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: #ffff99\">".$find[0]."</span>";

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

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

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

$value = str_replace($find, $replace, $value);
I'm not sure what else I need to do?

K
kleboe author 11/25/2012

Is anyone able to help with this? I am using version 6.2 of PHPRunner.
Any advice would be much appreciated! Thanks in advance

G
gudon 11/27/2012

Hi,
I am also interested in this function. I got some inspiration from here, but still could not figure out how to make it work with PHPR.
With anywhereindb, the query extracts all the returned records and re-writes them wrapping the matching text with a new class. Then the texts under this class are highlighted using CSS.