SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

MOSS 2007: Customize the Search Result (using XSLT)

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

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

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:

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:

 

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 08-23-2007 10:22 PM by Tobias Zimmergren

Comments

15 Links Today (2007-08-24) wrote 15 Links Today (2007-08-24)
on 08-24-2007 10:22 AM

Pingback from  15 Links Today (2007-08-24)

Mark wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 08-30-2007 5:09 PM

Where would a person go to learn the actual editing part?  I have had two issues...one, I want to change the way the search results are displayed, mainly to make the doc name show up at the top, and I want to edit a search page besides the default one.  I dropped a search box in a library site, but I cannot edit the results page like I can the main one.  Thanks!

Tobias Zimmergren wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 09-01-2007 10:50 AM

Hi Mark and thanks for the comment.

I'll be posting a more in-depth post soon about XSLT and how you can customize the search results to show up excactly the way you want it to. I will show you how to do this in a very modern and quick fashion using SharePoint Designer and the Data View Web Part.

I'll try to be a bit more active on the blogging-part, starting Monday (as I'm going on vacation for 3 weeks)

Cheers

Tobias Zimmergren's thoughts on development wrote MOSS 2007: Customizing the Search Results Page (XSLT) - Part 2 - Add highlighting
on 09-01-2007 3:45 PM

In one of my previous blogposts I wrote about how you easily could alter the XSLT of a the Search Core

Blogger Loser » Blog Archive » MOSS 2007: Customizing the Search Results Page (XSLT) - Part 2 - Add highlighting wrote Blogger Loser » Blog Archive » MOSS 2007: Customizing the Search Results Page (XSLT) - Part 2 - Add highlighting
on 09-01-2007 4:14 PM

Pingback from  Blogger Loser  » Blog Archive   » MOSS 2007: Customizing the Search Results Page (XSLT) - Part 2 - Add highlighting

peter pan wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 09-19-2007 2:47 AM

"(I tend to say xhtml instead of html to mark the importance of web standards and cross-browser compatability)"

Yet, this page is not valid XHTML ;p

Tobias Zimmergren wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 09-19-2007 2:57 AM

Still, it's still important to understand what valid markup means and that it is highly recommended to follow the W3C's recommendations.

Luckily enough, I can blame the CommunityServer for producing bad markup ;)

PAtrick wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 09-30-2007 8:39 PM

Can i do the same if using WSSv3?

When i went to my search page in WSS v3.And clicked on Site Actions i couldn't see the Edit option to get to the wb part search.

Any ideas?

Shanghai Nooner wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 10-03-2007 12:37 PM

PAtrick: are u sure that u have the right permissions to do those actions? like edit the page and stuff. if you dont have access you will not see that button.

Tobias Zimmergren: good post. i like your posts abot search. please if you could do some deeper search-posts with xslt-orientation i woud be for ever greatfull

thanks

mswin wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 10-23-2007 3:15 AM

Hi,

Really good post on search results customization.

Is it possible to identify the browser language setting in xsl. I am trying to create the site variations for MOSS search center. In our case the search is configured using BDC.

1. In the results displayed I want to show the column names in translated locale,

2.I want to change the action URL to point to the correct variation site.

Is this possible through xslt.

Can xsl interact with some xml or resource file. I want to get the translated column names from xml file/resource file ans use it for rendering.

Any help will be appreciated.

Nancy wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 10-25-2007 1:19 PM

Thanks for the post.  

Can you tell me how to modify whatever I need to modify in the XSLT to allow only PDF, XLS, and PPT filetypes to show up in the search results?  I appreciate any info, advice, or resources you can send me to.

Thanks.

SharePoint, SharePoint and stuff wrote SharePoint Kaffeetasse 27
on 10-29-2007 11:22 AM

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

SharePoint, SharePoint and stuff wrote SPPD079 SharePointPodcast
on 11-01-2007 8:38 AM

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

SharePointPodcast.de wrote SPPD079 SharePointPodcast
on 11-01-2007 8:39 AM

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

SBTSS wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 11-03-2007 6:49 AM

Can the results customization be done similar to something in SearchBlox.? They have a nice gui based search results editor where you can set the css styles for the xsl. You can also edit the xsl files directly.

www.searchblox.com

Mirrored Blogs wrote SPPD079 SharePointPodcast
on 01-09-2008 6:58 PM

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

Bala wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 03-03-2008 5:51 PM

Tob,

Do you have any tips in customizing the search?

In sense, to get the search parameters customised to fetch the search results?

Regards,

Bala

Robert wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 03-26-2008 6:50 PM

How do you customise the search results so you can select and edit a file?  

In SP 2003, there was a drop down box for "Edit in <approriate app>", which gave automatic save back into SP (without version comments) or you could to Edit Properties to Check-out the file and then select Edit in <app> with automatic save back into SP with version comments.

Neither direct editing  or Checkout is available in the default install.

Thank you.

Angelo wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 03-27-2008 2:03 PM

One thing that I am trying to do is to make the search results actionable. meaning if the result is a document, be able to check out the document from the search results page, but so far no luck.... any ideas?

Michael wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 04-01-2008 4:47 AM

I noticed that there is xslt 1.0 supported. How can I use xslt 2.0 with MOSS?

Tobias Zimmergren wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 04-01-2008 11:15 AM

I moved the blog to www.zimmergren.net - please post your comments there, and I'll happily answer them! :) Thanks

Charlie Brewer wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 04-14-2008 1:56 PM

My company Shaepoint Site is using WSS 3.0 .  The "Site Actions -> Edit Page "  is not available in the search results page.  Is this not an option in WSS 3.0?

Rajmahesh wrote re: MOSS 2007: Customize the Search Result (using XSLT)
on 02-24-2009 4:39 AM

Hi, My search is matching and listing all the site names also. Is it possible to display only pages and hide the sites.

Thanks

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.