I think my xslt may not be formatted correctly

亡梦爱人 提交于 2019-12-13 07:04:04

问题


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:


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>


来源:https://stackoverflow.com/questions/11614131/i-think-my-xslt-may-not-be-formatted-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!