Featured Post
Customizing Search Results with Custom XSLTs in SharePoint Server 2007
- Get link
- X
- Other Apps
Introduction
When users perform search queries by using Microsoft Office SharePoint Server 2007, the search results are rendered by the Search Core Results Web Part. The rendered HTML that users see is actually an XSLT transformation applied to the XML that contains the search results. If you want to change the color and layout of this page then below are the some tricks to apply these changes.
First of all, we should understant that what is Search Core Results web parth. This web part is inbuild web part provided by the MS Office Sharepoint Sever 2007 for searching records in the sharepoint site. This web part contain the settings related to search scope,layout and etc. 1. Open the sharepoint page in edit mode and add search core result web part. 2. In the Bottom Zone, in the Search Core Results Web Part, click edit, and then click Modify Shared Web Part. 3. In the Search Core Results tool pane, click XSL Editor. Create an empty XML file by using Microsoft Visual Studio 2005, and then copy all the XSLT into the XML file. 4. If you want to change the background color of searched text: Search Code : Below are the tags that exist after above mentioned tag : 5. If you want to change the background color of page, spaces from top/bottom/left write and want to add line in the top/bottom of the search result page: Search Code :Background
Custom change in the XSLT file:
//
// <xsl:template match="ddd">
// in the XSLT file
<xsl:template match="c0">
The above mentioned tag exist from c0-c9. For displaying background color in searched text, you need to add the span tag above the "b" tag.
<b><xsl:value-of select="."/></b>
</xsl:template>
<xsl:template match="c1">
<b><xsl:value-of select="."/></b>
</xsl:template> <xsl:template match="c0">
<span style="background-color:yellow">
<b><xsl:value-of select="."/></b>
</span>
</xsl:template>
<xsl:template match="c1">
<span style="background-color:yellow">
<b><xsl:value-of select="."/></b>
</span>
</xsl:template> //
//
<xsl:template name="dvt_1.body">
// in the XSLT file
//Add div tag below the above mentioned tag:
<div class="srch-results" style="background-color:#f0f0f0;border-top: #999 1px solid;border-bottom: #999 1px solid;padding-top:1px;padding-bottom:1px;padding-left:1px;padding-right:1px">
After doing these changes,save the xslt file then you will be ablt to see the above mentioned changes in your search result page.
Search results returned by the search engine are returned in XML format. The Search Core Results Web Part takes this XML as input and then applies an XSL transformation on the XML to render the HTML that users see on the search results page. This XSLT is public; it can be modified and replaced with custom XSLT to display results according to your requirements.
- Get link
- X
- Other Apps
Comments