in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Tobias Zimmergren's thoughts on development - MOVED!

THIS BLOG HAS MOVED!!!
NEW URL: www.zimmergren.net
Please update your RSS and bookmarks!

Any comments here will not be answered, please comment on http://www.zimmergren.net instead!
All the same posts are there

MOSS 2007: Customizing the Search Results Page (XSLT) - Part 2 - Add highlighting

Author: Tobias Zimmergren
Url:
http://www.sharepointblogs.com/zimmer

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)

Study the following XSLT, as per MSDN:

<hithighlightedsummary>
  <c0>SharePoint</c0> <c1>namespace</c1> provides types and members that can be used for working with a <c0>SharePoint</c0> site  <ddd /> a top-level <c2>class</c2> that represents a <c0>SharePoint</c0> site and provides access to its collection of subsites <ddd /> <c0>SharePoint</c0> <c1>namespace</c1> and a brief description of each.
</hithighlightedsummary>
<hithighlightedproperties>
  <HHTitle>Microsoft.<c0>SharePoint</c0> <c1>Namespace</c1></HHTitle>
  <HHUrl>
http://msdn.microsoft.com/library/default.asp?url=/library/en-     us/spptsdk/html/tsnsMicrosoft<c0>SharePoint</c0>_SV01017995.asp</HHUrl>
</hithighlightedproperties>

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

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):

<xsl:template name="Hithightlighting">

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 <b> tag (I replaced it with a <strong> tag instead, for sake of standards)
Then you can simply specify the styles for each highlighted word as picted in the following screenshot:

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

Comments

 

Erin said:

Hi,

Great post!

I'm having an issue that's related. I'm trying to get  the "AboutMe" property to show up in Search. I've imported a bunch of data using a BDC into the People properties (like Department, Skills and About Me.) I can get Skills and Department to show up in the People Results Search - but not the About Me data.

I've mapped the property, run the index (many times), checked my syntax in the xslt - still stumped. Do you know of any reason that the AboutMe wouldn't show up?

Thanks for your time!

September 6, 2007 9:16 PM
 

austin community college blackboard learning said:

austin community college blackboard learning

September 8, 2007 12:10 PM
 

Courtney Shoell said:

You forgot to mention that you will be required to remove the closing tag that would be </b>

Replace the closing tag </b> with </strong>

But then I am sure you knew this.

Thx for the tip.

October 19, 2007 11:46 AM
 

SharePoint, SharePoint and stuff said:

The latest news and gossip from SharePoint-Land :-) OT aber eigentlich doch nicht Microsoft kauft sich

October 29, 2007 11:22 AM
 

SharePoint, SharePoint and stuff said:

Direkter Download: SPPD-079-2007-11-01 Aktuell Linkssammlung Zielgruppen SharePoint Backup und Restore

November 1, 2007 8:38 AM
 

SharePointPodcast.de said:

Direkter Download: SPPD-079-2007-11-01 Aktuell Linkssammlung Zielgruppen SharePoint Backup und Restore

November 1, 2007 8:39 AM
 

mswin said:

Hi,

Its a great post.

Here it is shown how to configure the Hithighlighting template. I have a requirement to hithighlight the managed properties exposed BY BDC, the properties will be like CustomerName, Address so on....

Can we make hithighlighting work for this properties also not only for builin Title, URL properties.

Thanks in Advance

November 20, 2007 1:15 AM
 

Mirrored Blogs said:

Direkter Download: SPPD-079-2007-11-01 Aktuell Linkssammlung Zielgruppen SharePoint Backup und Restore

January 9, 2008 6:58 PM
 

chandrika said:

i have imported the live search results webpart in to the sharepoint site but results are not displayed for live search webpart.

help me in this context

Thanks in advance

March 12, 2008 5:10 AM
 

MaxGXL Benefits of Glutathione » MaxGXL Glutathione said:

What really concerns me about this is the Fascistic bent of the courts decision. They seem to feel they know better how to raise and teach our children then we do. They are OUR children not the governments children. For years the school system has been

April 3, 2008 3:00 PM
 

John said:

What about viewing the results in an "explorer view"-type interface?  Is it possible to design the XSLT to display links in the form of a list that can be drag-and-dropped?

May 21, 2008 1:13 PM
 

remandlo said:

good article,

I wanna display only the title on my search results but when trimming the other stuff out I only titles listed but separated with a line. tried to google about this wot I get is that the cause for the horizontal line separating the search results items is the  <p class="srch-Metadata"> line.

Has anyone of you guys managed to get this one right?

August 15, 2008 6:07 AM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts