The out-of-the-box SharePoint search results web part doesn't provide a way to get to the View Properties page for items in a document library. The search results provide a direct link to the document which will open a document in default editor registered within windows.

In the screen shot below notice that both the hyperlinked title (shown in the tool tip) and the url displayed both link to the actual document and not to the View Details page.

clip_image001

The goal is to generate a hyperlink that will allow the user to navigate to the properties display form for documents.

clip_image002

Clicking "View Properties" will take the user to the following page:

clip_image003

Step 1: Add a managed property for the integer ID of list items.

In order for the solution to work properly we must first create a Metadata Property Mapping for the ID of list items. SharePoint out-of-the-box does not include these identifiers in its search index.

  1. Open the SSP
  2. Click Search Administration
  3. Under Queries and Results, click Metadata properties.
  4. Click Crawled Properties:
    clip_image004
  5. Search for ows_id. Then edit the crawled property.
    clip_image005
  6. Select the checkbox at the bottom of the page to include the property in the search index:
    clip_image006
  7. Return to the Metadata Property Mappings screen by clicking on Metadata properties on the left side of the page.
  8. Click New Managed Property and set the values as follows:
    • Property Name: ListItemID
    • Description: Numeric identifier of SharePoint List Items (i.e. documents, pictures, and custom lists).
    • Type: Integer
    • Add ows_id as a crawled property.
  9. Run a full crawl of the content source

Step 2: Add the Metadata property to the search results web part

Now that the metadata property has been added to SharePoint we now need to make the property available to the search results web part. In my example I've added the search and search results web parts to a web part page but the same steps apply if you are editing the search results web part in the search center.

  1. Open your search results page in edit mode.
  2. Locate the search results web part and click Modify Shared Web Part
    clip_image007
  3. In the Results Query Options section, open the editor for the Selected Columns property:
    clip_image008
  4. Add a reference to the ListItemId property as follows:
    <Column Name="ListItemID" /> 

    At this point the custom Metadata property we created will now be retrieved with every search query. The value will come back in the xml returned by the query servers and is just begging to be displayed somewhere on the page.

Step 3: Modify the XSL to display the hyperlink to the View Properties page.

The next step it to create a hyperlink to the View Properties page using not only the custom ListItemId Metadata property but also several other properties already available to us: url, sitename, and contentclass.

  1. Click the XSL Editor button in the web part properties panel.
  2. Copy the contents of the editor and paste into an XSL editor like Visual Studio .NET or any text editor.
  3. Near the bottom of the XSL file paste in the following template definition just prior to the </xsl:stylesheet> tag:
    <!-- A custom template to display a link to view the properties for a document -->
    <xsl:template name="DisplayViewPropertiesLink">
      <xsl:param name="itemUrl" />
      <xsl:param name="siteUrl" />
      <xsl:param name="listItemId" />
      <xsl:param name="contentclass" />
      <xsl:if test="$contentclass='STS_ListItem_DocumentLibrary'">
        <xsl:variable name="docLibLoc" select="substring-before(substring-after($itemUrl, concat($siteUrl, '/')), '/')" />
        <xsl:variable name="viewPropUrl" select="concat($siteUrl, '/', $docLibLoc, '/Forms/DispForm.aspx?id=', $listItemId)" />
        - <a href="{$viewPropUrl}">View Properties</a>
      </xsl:if>
    </xsl:template>

    This template first checks to see if the item is part of a document library. If so, it parses out the document library name and then builds up a URL pointing to the View Properties page and outputs a hyperlink to the page.

    Important note: This link is hard-coded to point to the out-of-the-box View Properties page. If document libraries have custom View Properties pages, this solution will need to be modified.

  4. The last step is to include a call to the new StyleSheet template. In my example, I've placed the call just after the rendering of the modified date:
    <xsl:call-template name="DisplayString">
      <xsl:with-param name="str" select="write" />
    </xsl:call-template>
    
    <xsl:call-template name="DisplayViewPropertiesLink">
      <xsl:with-param name="itemUrl" select="url" />
      <xsl:with-param name="siteUrl" select="sitename" />
      <xsl:with-param name="listItemId" select="listitemid" />
      <xsl:with-param name="contentclass" select="contentclass" />
    </xsl:call-template>
    
    <xsl:call-template name="DisplayCollapsingStatusLink">

    Step 4: Deploy and test

    Now that the XSL StyleSheet has been modified the last step is to copy the XSL back into the web part property and save your changes. Submit a simple search for documents and verify the View Properties link appears after the date.

    clip_image009

Special thanks to Jeremy Jameson for providing the idea and starter code for this solution.