Looking for something?

Author: Tobias Zimmergren
Url: http://www.zimmergren.net

In one of my previous blogposts I wrote about how you easily could alter the XSLT of a the Search Core Results Web Part on your Search Results Page in order to achieve a customization to the presentation of the output.

In this article I will scratch on the surface of some more XSLT and show you how you can implement the HitHighligting Template in order to achieve colored/customized display of the search words you entered.

What is the HitHighligting Template?

Well, basically the HitHighligting template offers you the ability to highlight words that are used in your search. It offers you the possibility to highlight words in the following three result sections: Title, Url and Description (And that’s basically all you need, mostly)

 searchresultstwo1

Study the following XSLT, as per MSDN:

*   \<c0>SharePointnamespaceSharePoint a top-level \<c2>classSharePoint \<c0>SharePointnamespace   Microsoft.\<c0>SharePointNamespace  * \http://msdn.microsoft.com/library/default.asp?url=/library/en-](http://msdn.microsoft.com/library/default.asp?url=/library/en-)*     us/spptsdk/html/tsnsMicrosoft\<c0>SharePoint *

You may notice that the sections hithighlightedsummary, HHtitle and HHUrl elements contain childs (\<c0>,\<c1> etc). This basically means that for each instance of the words entered in your search, you get a set of highlight-tags that encloses that word. This is the default behaviour of the SharePoint Search. First word gets \<c0>, second word gets \<c1> and so on…

How do I add the Highlighting functionality?

Note: If you do not know how to access the XSLT of the Search Core Results Web Part, view my previous post on the subject.

In order to customize the presentation of the search result and make your words highlighted, you basically only need to add some tags to the XSL-template for each search word you want to highlight as you can see in the screenshot below.

Now locate the following section in your Search Core Results Web Part (It already exist):


And since this template exists from the beginning, all you really have to do is to customize the style attribute and add a color property of the * tag (I replaced it with a * tag instead, for sake of standards)
Then you can simply specify the styles for each highlighted word as picted in the following screenshot:

 searchresultstwo2

It’s simple as that. I hope this helped some of you to get started on some basic Search Core Results XSLT customizations.

0 Comments 01 September 2007
Tobias Zimmergren

Tobias Zimmergren

Hi, I'm Tobias. I am a Microsoft MVP for SharePoint and I use this site to share my thoughts on tech with you on topics like SharePoint, Office 365, Azure and general web development.

  Malmö, Sweden

Related Post

Comments powered by Disqus
res.