Tags

,

After reading Cherry Bites’s blog, I spend some time to understand the XSL in search result.

A full tutorial about the XSL is here.

The XSL to display content type as below
This can easily be implemented into the search results web part in MOSS

<xsl:template name="GetContentType">
    <xsl:param name="SharePointContentType"></xsl:param>
  <xsl:if test='string-length($SharePointContentType) &gt; 0'>   
   - 
  </xsl:if>
    <xsl:choose>
        <xsl:when test="contains($SharePointContentType,'STS_Web')">Site</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_850')">Page Library</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_850')">Page</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_DocumentLibrary')">Document Library</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_DocumentLibrary')">Document Library Items</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_Links')">Links List</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_Links')">Links List Item</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_Tasks')">Tasks List</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_Tasks')">Tasks List Item</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_Events')">Events List</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_Events')">Events List Item</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_Announcements')">Announcements List</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_Announcements')">Announcements List Item</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_Contacts')">Contacts List</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_Contacts')">Contacts List Item</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_DiscussionBoard')">Discussion List</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_DiscussionBoard')">Discussion List Item</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_IssueTracking')">Issue Tracking List</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_IssueTracking')">Issue Tracking List Item</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_GanttTasks')">Project Tasks List</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_GanttTasks')">Project Tasks List Item</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_Survey')">Survey List</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_Survey')">Survey List Item</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_PictureLibrary')">Picture Library</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_PictureLibrary')">Picture Library Item</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_WebPageLibrary')">Web Page Library</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_WebPageLibrary')">Web Page Library Item</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List_XMLForm')">Form Library</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem_XMLForm')">Form Library Item</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_ListItem')">Custom List Item</xsl:when>
        <xsl:when test="contains($SharePointContentType,'STS_List')">Custom List</xsl:when>            
        <xsl:when test="contains($SharePointContentType,'urn:content-class:SPSSearchQuery')">Search Query</xsl:when>
        <xsl:when test="contains($SharePointContentType,'urn:content-class:SPSListing:News')">News Listing</xsl:when>
        <xsl:when test="contains($SharePointContentType,'urn:content-class:SPSPeople')">People</xsl:when>
        <xsl:when test="contains($SharePointContentType,'urn:content-class:SPSCategory')">Category</xsl:when>
        <xsl:when test="contains($SharePointContentType,'urn:content-class:SPSListing')">Listing</xsl:when>
        <xsl:when test="contains($SharePointContentType,'urn:content-class:SPSPersonListing')">Person Listing</xsl:when>
        <xsl:when test="contains($SharePointContentType,'urn:content-class:SPSTextListing')">Text Listing</xsl:when>
        <xsl:when test="contains($SharePointContentType,'urn:content-class:SPSSiteListing')">Site Listing</xsl:when>
        <xsl:when test="contains($SharePointContentType,'urn:content-class:SPSSiteRegistry')">Site Registry Listing</xsl:when>
        <xsl:otherwise>
            Webpage (<xsl:value-of select="$SharePointContentType"/>)
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

Then to reference this in your search results simply call this template and pass in the variable ‘contentclass’ which appears on all search result pages:

<xsl:call-template name="GetContentType">
     <xsl:with-param name="SharePointContentType" select="contentclass"/>
</xsl:call-template>
Advertisements