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.
The goal is to generate a hyperlink that will allow the user to navigate to the properties display form for documents.
Clicking "View Properties" will take the user to the following page:
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.
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.
<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.
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.
<!-- 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.
<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">
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.
Special thanks to Jeremy Jameson for providing the idea and starter code for this solution.