SharePoint 2010 Search Result file icon change

混江龙づ霸主 提交于 2019-12-23 01:13:47

问题


I am trying to change the aspx file icon from default icon to customized icon. I edited the xsl of the results.aspx page "fetched properties" for this section. I wanted to make sure that LegalDoc16.gif icons are displayed for the items who has "LegalDocument" content type. Please let me know if I dont have to syntaxed properly configured. I can do a search like ContentType:"legaldocument" and I get all the documents. so I know contenttype metadata property is being pulled. Please suggest.

  <div class="srch-Icon" id="{concat($currentId,'_Icon')}"> 
    <xsl:choose>
        <xsl:when test="string(ContentType)='LegalDocument'">
            <img align="absmiddle" src="_layouts/images/LegalDoc16.gif" border="0" alt="{imageurl/@imageurldescription}" />
        </xsl:when>
        <xsl:otherwise>
            <img align="absmiddle" src="{imageurl}" border="0" alt="{imageurl/@imageurldescription}" />
        </xsl:otherwise>  
    </xsl:choose>   
  </div>

回答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 = 'LegalDocument'">
        <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>

P.S. This question is possibly a duplicate of I think my xslt may not be formatted correctly




回答2:


Everthing was fine. All I had to do before running the powershell, go to the document library and add a file based on Linked to Document (and delete the test upload file). After that it worked.



来源:https://stackoverflow.com/questions/11617102/sharepoint-2010-search-result-file-icon-change

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