I think my xslt may not be formatted correctly

2019-09-04 23:07发布

I am trying to change the icon for the "Link to Document" on the searchResult.aspx page. I added following to the xslt of the result but then the result webpart never renders meaning the code is broke. I tried to follow SP2007 article (http://msdn.microsoft.com/en-us/library/cc789805(v=office.12).aspx) but my environment is SP 2010. Please suggest.

<div class="srch-Icon" id="{concat($currentId,'_Icon')}"> 
<xsl:if test="contenttype='LegalLinkedDocument'">  
    <img align="absmiddle" src="_layouts/images/legalLinkedIcon.gif" border="0" alt="{imageurl/@imageurldescription}" />
</xsl:if>
    <img align="absmiddle" src="{imageurl}" border="0" alt="{imageurl/@imageurldescription}" />

1条回答
走好不送
2楼-- · 2019-09-04 23:59

I believe there is a bug that prevents the ContentType metadata property being used (see http://social.msdn.microsoft.com/Forums/en/sharepoint2010general/thread/cd059e1c-7af6-454c-8568-a22e7755ce8c)

You need to create a new managed metadata property and map it to the ows_ContentType crawled property (I called mine CType), after this do a full crawl (you may need to delete the index first) to have the property available in the search index.

Then edit the Search Core Results web part and add

 <Column Name="CType"/>

to Fetched Properties (under Display Properties) after <columns>

Then update your xml to the following

<xsl:choose>
    <xsl:when test="ctype = 'LegalLinkedDocument'">
        <img align="absmiddle" src="_layouts/images/LegalLinkedDocument.gif" border="0" alt="{imageurl/@imageurldescription}" />
    </xsl:when> 
    <xsl:otherwise>
        <img align="absmiddle" src="{imageurl}" border="0" alt="{imageurl/@imageurldescription}" />
    </xsl:otherwise>
</xsl:choose>
查看更多
登录 后发表回答