- adding a new item link allowing to open the item
- adding a link directing to the location where the result comes from
- removing the default URL which is shown at the bottom of a search result
Let's start easy with creating a link to the item. This is actually just creating an href tag:
<a href="{url}">Open file</a>
The {url} reference is the default shown at the bottom of the result, as well the link used when you click the result title.Adding a link to the parent location
Now, this supposed to be an easy one; add something like the url and that's it... But in vain... So I resorted to two methods; using data view web part and using the raw xml. Assuming that I would have to dig deep, I went on and used the data view web part. The two best options to use were 'Path' and 'FileDirRef'. Unfortunately the FileDirRef gave me no results, and the 'Path' always showed me the parent location of the results.aspx page.
So on to the next option; using the raw xml.
How does this work;
- you have xml-values coming in
- you style these using the xsl
- using the raw xml styling, you can get the actual values coming in (and thus verifying if all values are found). Use following xsl to get the raw XML (don't forget to save the original xsl... just in case).
<?xml version="1.0" encoding="UTF-8"?>
<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>
<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>
I was a bit astonished about the results... all of a suddon, within the xml results, there was a field called 'sitename'... but the value was exactly what I needed... the location where the item came from.
Thus, on to the next step... creating the link:
<a href="{sitename}">Open file Location</a>
Removing the original URL
And to finish... an easy one on the removal of the original URL. Look for following code in the xsl sheet, and remove the italic part:
<p class="srch-Metadata1">
<span><span class="srch-URL2" id="{concat($currentId,'_Url')}">
<xsl:choose>
<xsl:when test="hithighlightedproperties/HHUrl[. != '']">
<xsl:call-template name="HitHighlighting">
<xsl:with-param name="hh" select="hithighlightedproperties/HHUrl" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="url"/>
</xsl:otherwise>
</xsl:choose>
</span>
<xsl:call-template name="DisplayCollapsingStatusLink">
voila, that's it... enjoy playing with the xsl... gonna add some screens tomorrow