How to highlight match text in the title just like google?
I was able to modify the highlighted text within the preview area but I just wanted to implement that in the title as well. Anybody knows how to modify xsltsearch? Thanks
The modifications required to do this are actually only pretty minor. I've pasted the whole thing here - latest version of XSLTSearch (3.0.1): http://pastebin.com/AgqhEfDx
All you need to do is replace the page title in the search results:
<!-- page name and url --> <a href="{umbraco.library:NiceUrl(@id)}" class="xsltsearch_title"> <xsl:value-of select="@nodeName /> </a>
With the code that does the highlighting, which I just grabbed from the results description:
<!-- page name and url -->
<a href="{umbraco.library:NiceUrl(@id)}" class="xsltsearch_title">
<xsl:value-of select="PS.XSLTsearch:surround(@nodeName, $search, $before, $after)" disable-output-escaping="yes" />
</a>
The only other thing to do is make sure the variables which determine what mark-up is used to perform the highlight ($before and $after, defined as <strong> and </strong> by default) are defined above the page title, so for simplicity I've moved these to the top of the script.
I've not tested this thoroughly but a quick proof-of-concept seemed to work fine.
How to highlight match text in the title just like google?
I was able to modify the highlighted text within the preview area but I just wanted to implement that in the title as well. Anybody knows how to modify xsltsearch? Thanks
Hi Jeffrey,
The modifications required to do this are actually only pretty minor. I've pasted the whole thing here - latest version of XSLTSearch (3.0.1): http://pastebin.com/AgqhEfDx
All you need to do is replace the page title in the search results:
With the code that does the highlighting, which I just grabbed from the results description:
The only other thing to do is make sure the variables which determine what mark-up is used to perform the highlight ($before and $after, defined as <strong> and </strong> by default) are defined above the page title, so for simplicity I've moved these to the top of the script.
I've not tested this thoroughly but a quick proof-of-concept seemed to work fine.
Thanks Dan, coooool!!!!!! thanks a lot!!!!
Hi Dan, it's perfectly working! Thanks a lot!
is working on a reply...