View Full Version : Highlight Search Terms
web_assist_mail157665
07-02-2009, 02:36 AM
Any thoughts on how to do this on the text search results
I see $_SESSION['WADbSearch1_search'] holds the search where clause
ie OR (((text_art LIKE '%Luton%')) OR ((text_art LIKE '%Partnership%')))
My page content recordset displays text that contains these terms and would appreciate any thoughts on matching these in PHP
ie
IF ARTICLE_TEXT = ONE OF THESE WORDS IN THE SESSION VAR, THEN SURROUND ARTICLE TEXT WITH SPAN HIGHLIGHT
While ignoring any HTML tags
Ray Borduin
07-02-2009, 07:30 AM
We don't offer a solution for this.
Basically you would want to isolate the search terms into an array.
Then write a function that probably takes the search term array and the starting text as an argument and returns the text with the added spans.
Then you would use a regular expression match while looping through the array to do the replacement. Since you only pass in the content, there are no html tags to ignore, but you could use a regular expression to remove tags first before doing replacements if necessary as well.
web_assist_mail157665
07-21-2009, 04:12 AM
We don't offer a solution for this.
Basically you would want to isolate the search terms into an array.
Then write a function that probably takes the search term array and the starting text as an argument and returns the text with the added spans.
Then you would use a regular expression match while looping through the array to do the replacement. Since you only pass in the content, there are no html tags to ignore, but you could use a regular expression to remove tags first before doing replacements if necessary as well.
Please add this to feature request list
2 options, 1 feature
Highlight part words
Highlight only complete words
Use different colours to highlight different words in search list
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.