How to customise search core results web part Part1
        Posted  
        
            by ybbest
        on YBBest
        
        See other posts from YBBest
        
            or by ybbest
        
        
        
        Published on Tue, 13 Mar 2012 00:11:43 +0000
        Indexed on 
            2012/03/19
            2:17 UTC
        
        
        Read the original article
        Hit count: 899
        
SharePoint 2010
|enterprise search
|search
|SharePoint Enterprise
|SharePoint Search
|sharepoint2010
In this post, I’d like to show you how to customise search core results web part. It is a quite simple, most of the times what you need to do is to change the xslt to perform the changes. Here are the steps:
1. You need to change the xslt to the following, so that you can see the raw xml.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" /> <xsl:template match="/"> <xmp><xsl:copy-of select="*"/></xmp> </xsl:template> </xsl:stylesheet>

b. Open the xslt editor and copy the existing XSLT code to your preferred xslt editor so that you can customise it.

2.Perform the search after you have completed step1 and you will see the search results returned in raw xml
<All_Results>
    <Result>
      <id>1</id>
      <workid>678</workid>
      <rank>100000000</rank>
      <title>Ybbest</title>
      <author></author>
      <size>137531</size>
      <url>http://ybbest</url>
      <urlEncoded>http%3A%2F%2Fybbest</urlEncoded>
      <description>Ybbest test site</description>
      <write>3/17/2012</write>
      <sitename>http://ybbest</sitename>
      <collapsingstatus>0</collapsingstatus>
      <hithighlightedsummary>
        <c0>Ybbest</c0> test site <ddd /> Add a new image, change this welcome text or add new lists to this page by clicking the edit button above. You can click on Shared Documents to add files or on the <ddd /> </hithighlightedsummary>
      <hithighlightedproperties>
        <HHTitle>
          <c0>Ybbest</c0>
        </HHTitle>
        <HHUrl>http://<c0>ybbest</c0></HHUrl>
      </hithighlightedproperties>
      <contentclass>STS_Site</contentclass>
      <isdocument>False</isdocument>
      <picturethumbnailurl></picturethumbnailurl>
      <popularsocialtags />
      <picturewidth>0</picturewidth>
      <pictureheight>0</pictureheight>
      <datepicturetaken></datepicturetaken>
      <serverredirectedurl></serverredirectedurl>
      <fileextension></fileextension>
      <ows_metadatafacetinfo></ows_metadatafacetinfo>
      <imageurl imageurldescription="SharePoint Site Collection">/_layouts/images/siteicon_16x16.png</imageurl>
    </Result>
 <TotalResults>69</TotalResults>
    <NumberOfResults>50</NumberOfResults>
  </All_Results>
3. Then you can read what has been returned in the raw xml and start modifying the xslt to customise your search results page.
4.You can also link an external xslt to the web part.It can be set in the Miscellaneous of Web Part section.
You can also set it pragmatically using a feature receiver , you can download the source code to do so here.
References:
© YBBest or respective owner
