Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeffrey Valeroso 40 posts 101 karma points
    Aug 04, 2012 @ 03:28
    Jeffrey Valeroso
    0

    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

  • Dan 1285 posts 3917 karma points c-trib
    Aug 04, 2012 @ 09:39
    Dan
    2

    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:

    <!-- 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.

  • Jeffrey Valeroso 40 posts 101 karma points
    Aug 04, 2012 @ 19:26
    Jeffrey Valeroso
    0

    Thanks Dan, coooool!!!!!! thanks a lot!!!!

  • Jeffrey Valeroso 40 posts 101 karma points
    Aug 06, 2012 @ 04:03
    Jeffrey Valeroso
    0

    Hi Dan, it's perfectly working! Thanks a lot!

Please Sign in or register to post replies

Write your reply to:

Draft