# How to highlight the searched keyword on results page?

When you search in Magento, on search result page you will see the results with below text for example,

Search results for 'configure'

Here my search keyword is configure.

How can I highlight the searched keyword on results page ?

Thanks

That can be found in app\design\frontend\base\default\template\catalogsearch\result.phtml. So create a local copy of that file in your theme and add some code/CSS to highlight your search term.

The code will look like that:

<h1><?php echo ($this->getHeaderText() ||$this->getHeaderText() === false) ? $this->getHeaderText() :$this->__("Search results for '%s'", $this->helper('catalogsearch')->getEscapedQueryText()) ?></h1>  The search term itself comes from: $this->helper('catalogsearch')->getEscapedQueryText()


So you can take that out and add some element around it with a class or id. After that add a style for that class or id, something like:

.yourGivenClass {
background-color: yellow;

• Well, in that case you have to open the template file and get the name or the description (do you display the description on the search result page at all?) and use a regular expression to search for your seach term in for example the name of the product. If found, replace (preg_replace) the match with <span class="yourGivenClass">\$term</span>. That should do it. – user1638055 May 5 '14 at 11:53