OOTB the Search Core Results webpart simply emphasizes the search string you entered in the Search Box by wrapping it within the <b></b> tags. But let’s say you need to highlight the search terms in different colors; what do you do? Write a new results webpart? No! you only need to adjust the Search Core Results XLS.
This is how it’s done:
- Open up the XLS editor and copy the contents to notepad or some other editor (if your fine with editing it in the MOSS’s default editor, go right ahead)
- Search for the term <xsl:template match="ddd">
- Just below that you will see :
<xsl:template match="c0">
<b><xsl:value-of select="."/></b>
</xsl:template>
<xsl:template match="c1">
<b><xsl:value-of select="."/></b>
</xsl:template>
And this goes on till “c9”. The values “c0” to “c9” correspond to the search terms you entered, where “c0” is the first, “c1” is the second and so on…
- Replace this with something like:
<xsl:template match="c0">
<strong style="background-color: #CCCCFF">
<xsl:value-of select="."/>
</strong>
</xsl:template>
<xsl:template match="c1">
<strong style="background-color: #CCFFFF">
<xsl:value-of select="."/>
</strong>
As you can see I’ve used the style “background-color” to give each search term its own color.
- Once done copy the updated XLS file back to the webpart and save
Searching for "
microsoft sharepoint server"
with the default XLS:
with the modified XLS: