MOSS 2007: Customize the Search Result (using XSLT) 

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

Since people have been bugging me to get started with the blogging again, I guess I should just take their advice and get to it.

This blogpost will cover the basics of customizing your search results-page using XSLT.

I will in a later blogpost also show you how you can use SharePoint Designer as a tool to create the actual XSLT for you in combination with the DataViewer Web Part, and then how you can modify the created XSLT to match whatever specifications you've got in your designs.

I would recommend creating a new Search Page and Search Results Page to use, but for this little demo I'll just use the default search page and search results page.

Let's get started then..

First of, take a look at the search results page (the page you see when you've made a search):
customsearchresultsone1 

From here, take the following actions:

  1. Choose Site Actions -> Edit Page
  2. Locate the "Search Core Results" web part, and choose "Edit" -> "Modify Shared WebPart"
  3. Locate "Data View Properties" and choose the huge "XSL Editor..." button :)

You should now see something like this:
customsearchresultsone2

Now all you need to do (if you wish to use the existing properties) is to add your custom xhtml (I tend to say xhtml instead of html to mark the importance of web standards and cross-browser compatability).

I just added some style-attributes to the body div and the results template span-tag to mark my point. I did by no means put any energy into making this look nice. Please believe me ;)

And this is the final "stylish" outcome:
customsearchresultsone3

 

What have we accomplished today then? Well, nothing big at all. Just a little tip on how you can customize the Search Result presentation with minimum knowledge or efforts. I however will in one of my next blogposts let you in on a little tip on how to use SharePoint Designer and the Data View Web Part to create the custom XSLT for you fully automatically instead of customizing the existing XSLT with your own xhtml. That basically means that it's dead-easy to change the looks, layout and appearance of the search results in a much more extensive!

That's a wrap!
By the way; I love comments and try to answer them, feel free to add one while you're here :)

 
Posted on 23-Aug-07 by Zimmergren
9 Comments  |  Trackback Url  |  Link to this post | Bookmark this post with:        
Tags: Search Results Page, Search, XSLT
 

Links to this post (Trackbacks/Pingbacks)

Comments

Sunday, 13 Apr 2008 10:32 by MT
I was wondering why Sharepoint allows you to attempt to edit the XSLT itself in the XSL Editor option in the Search Results, and in my case the People Core Search Results web part, when even if I copy back in the same exact code from notepade, it renders wrong. I simply wanted to remove the option to "Add to Collegues" as we have disabled My Sites in our system. However, references to it cannot be simply commented out, etc. In fact, any little thing I add or remove leads to rendering issues. Thanks for the post, I will try to follow the directions. But if you have already developed a simplified people search - hotlink name going to mailto: instead of My Sites and removing the Add to Colleagues for example, please pass it on...

Monday, 28 Jul 2008 07:16 by born2run
Hi, it's posible to change the document link (just above each result on the left of size and author properties) to the container library?

Name:
URL:
Email:
Comments:


MCTS WSS 3.0 (Developer and Administration/Configuration) MCTS MOSS 2007 (Developer and Administration/Configuration) MCP