Archive for January, 2010|Monthly archive page

Customizing Microsoft SharePoint search to display thumbnails of slides from slide library

Being in business development function I liked the slide library feature of Microsoft SharePoint as it helps in maintaining the corporate slide deck at a common place and also provides a way for distributed sales team to be always up to date with the latest collaterals.
In order to use this feature more effectively we needed a way to visually search the slides. The default search results are textual and displays an icon for file types, which wasn’t enough. After looking at various web sources it was apparent that no one(most likely) had attempted such customization. I think this should have been a standard feature, nevertheless let me explain the workaround and make your search experience with SharePoint slide library more visual for now.

Go to search Settings (through Site Actions -> Site Settings-> Site Collection Administration -> Search settings) and check the use custom scope and add “/_catalogs/masterpage/SearchResults.aspx”.

Search Settings

Figure 1: Search Settings

Now your search will use this page to render the results. We will have to customize this page and it will require modifying the relevant webpart for this page.

Please open the link
http://<SharePoint url >/_catalogs/masterpage/SearchResults.aspx?PageView=Shared

Go to Site Actions -> Edit Page


Figure 2: Modify Search Web Part

Once you click on Modify Shared Web Part( refer figure 2) you will see a button with caption as XSL Editor. Clicking the XSL editor will pop up a XSL editor window as shown in figure 3


Figure 3: XSL Editor

This is  the XSLT code which renders the search results for you. Currently it will contain some code which displays url as img src which basically shows the thumbnail based on the file types. Since we are interested in slides we will replace this img src code to show the thumbnail. The SharePoint slide library already keeps the thumbnail for all slides at a predefined location. The location is

http://<share point URL>/<name of slide library site>/_t/

The file name of the thumbnail follows the convention <slide file name>_pptx.jpg You may want to test this by directly giving the complete url for a particular slides. Something like

http://<share point URL>/<name of slide library site>/_t/<Powerpoint file>_pptx.jpg

Now look for XSLT code starting from

<!– This template is called for each result –>
<xsl:template match=”Result”>

This is the place where we will have to do the manipulation in the url to point to our thumbnail and you will be all set! Here is a snippet of what I did, not a very clean way to do it, so you may want to use any find replace template instead.

<!– This template is called for each result –>
<xsl:template match=”Result”>
 <xsl:variable name=”id” select=”id”/>
 <xsl:variable name=”url” select=”url”/>
<xsl:variable name=”temp1″ select=”concat(‘/_t’,substring-after($url,’Slide Library’))”/>
 <xsl:variable name=”temp2″ select=”concat(substring-before($url,’Slide Library’),’Slide Library’)”/>
<xsl:variable name=”temp3″ select=”concat($temp2,$temp1)”/>
<xsl:variable name=”thumbnail” select=”concat(substring-before($temp3,’.pptx’),’_pptx.jpg’)”/>
 <span class=”srch-Icon”> <a href=”{$url}” id=”{concat(‘CSR_IMG_’,$id)}” title=”{$url}”>
<img align=”absmiddle” src=”{$thumbnail}” border=”0″ /> </a> </span>

Hope this helps.
Useful Links