How can I get the results of a search to highlight the search terms in a page?
The searchterms.phpΔ script highlights any words in the page contents that were used in a search query to arrive at the current page. The script understands queries coming from external search engines such as Google and Yahoo! as well as PmWiki's Search feature.
When someone follows a page link coming from a search engine, the query that was used to locate the page is often available to the target site via the HTTP_REFERER variable. This recipe parses HTTP_REFERER to see what words were used in a query, and highlights any instances of those words within the page contents.
As an example, follow this link to have PmWiki search the cookbook for all pages containing the words "search" and "highlight". Then, follow the link from the search results page back to this one, which has the searchterms.phpΔ recipe enabled. You should see all of the instances of "search" and "highlight" displayed with a yellow background on this page.
Notes and Comments
This is similar to the SearchHighLight? recipe, except that it doesn't require any modifications to the skin to function. It also allows highlighting of terms in any wiki generated content, not just the main text.
The script currently does not support searches of the form 'group/text' -- the fix is to change
Is it possible to disable the highlighting inside the sidebar ? jmi
This ends up clashing with Backlinks. Adding
This looks great! One question though, I'd like a link occur on the top right side of the page, saying "Remove highlighting". This would be as simple as putting
Seems that the highlighting through google search doesn't work anymore...
It's working for me -- I just did a search at  and followed the link to this page, and "searchterms" is correctly highlighted. --Pm October 20, 2005, at 07:25 AM
Try again please, I can't see the highlighting in your example, not in mozilla and not in IE. Maybe Google changed something?
Elsni October 27, 2005, at 03:55 AM
Are you sure this recipe is still enabled and working with the current version of PmWiki. I tried the search example link (above) it on two systems (OS X and XP) with two different browsers (Safari and Firefox) and the searched terms were not highlighted). Pico May 30, 2006, at 03:31 PM
It's good. It works on English character, but not work on UNICODE character. what can i do. kksang