Resources for SharePoint Search Results Customization

Recently I had to modify a clients search results page to show the search results as a table and not as a list. After a long battle I found a few sources which I would like to share with other people. They might come in handy.


First link:

This is a great link from which I got alot of help. With this XSL file you can show your search results as a table.

Second link:

When you are working with search result you need sometimes to get a hold of the actual search results in XML format that is used by the xsl to be displayed to your page users. The following XSL piece of code copied and pasted in the search results webpart is going to show you the result in XML.

<xsl:stylesheet version=”1.0″
<xsl:output method=”xml” version=”1.0″ encoding=”UTF-8″ indent=”yes”/>
<xsl:template match=”/”>
  <xmp><xsl:copy-of select=”*”/></xmp>

I recommend the following link for more info:

It is a bit old 🙂 BUT still the information applies.

Lastly I want to share a solution I had to conjure up for the XSL file. My client wanted to have a link to a search document so that when you press that link it does not open you the document BUT it opens the document metadata properties in view mode. This was simple enough, just make an URL that points to the documents location, add the item ID to the view page of that library to show you the documents properties. One of the problems it that out of the box the ID field of the XSL is not the ID of the document in its library BUT the ID of the search result. Meaning that if you get 14 search results the ID is the position of the search result in the order it is in the retrieved through the search.

So to get it to work I had to create a new search “Metadata property” named ListItemID. This property uses the crawled property named “ows_ID” to get the documents REAL ID in the library it is located. Then I simply used this new search metadata property in my XSL and everything worked like a charm.

ANYWAY 🙂 below if the piece of XSL and HTML to display a link that allows a user to access the document properties in view mode. Alter it to get your desired functionality.

<a href=”{sitename}/Forms/DispForm.aspx?ID={number(ListItemID)}”>

I’ll explain a bit the above piece of code. The {sitename} will retrieve the list location where this item is located. The DispForm.aspx is a page that can be used to view documents. {number(ListItemID)} is simply a function that converts the ListItemID metadata property value into a number. You have to provide the document ID value to the aspx page. This way the ASPX page will retrieve the proper document information.


One thought on “Resources for SharePoint Search Results Customization

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s