I have a custom field in a BDC Entity with a field called “WebPage“, which is the path to a photograph of an employee.  (Note the mixed case, this will be important later).  I wanted to change output of the search results to display this picture. i.e. I want to go from this:

To this:

  A few steps were required:


1.   In the Shared Service Provider, Search Settings, Metadata Property Mappings…add a new Managed Property that points to the WebPage BDC field:



2.  Make sure the BDC is added as a Content Source (SSP, Search Settings, Content sources and crawl schedules) and scope for the BDC application. and do a full crawl of the BDC content source.
3.  Create a custom scope and custom search page (see http://blah.winsmarts.com/2007-4-SharePoint_2007__BDC_-_Enabling_Search_on_business_data.aspx for a example)


4.  Modify the Search Core Results web part:  Add the custom column to the list of Selected Columns:



Also under Miscellaneous properties, set the Scope to be your BDC search scope.

and then proceed to modify the XSLT…


I found this snippet of XSLT from Patricks article , which outputs the search results as straight XML, to be very uesful for troubleshooting problems:












<?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>


Here is a small snippet of the output.  NOTE that the field is lower case “webpage“, even though our Managed Property is mixed case “WebPage“.  This is very important in the XSLT that you will write to display this field data!!:



So now, I put the original XSLT back.  I want to replace the original small icon that comes back, with a picture located in the WebPage variable path:


So I found this bit:


<xsl:template match=”Result”>
  <xsl:variable name=”id” select=”id”/>
  <xsl:variable name=”url” select=”url”/>
  <span class=”srch-Icon”>
   <a href=”{$url}” id=”{concat(‘CSR_IMG_’,$id)}” title=”{$url}”>
   <img align=”absmiddle” src=”{imageurl}” border=”0″ alt=”{imageurl/@imageurldescription}” />
   </a>
  </span>


which gives us this result:



and replaced it with this bit:



<xsl:template match=”Result”>
  <xsl:variable name=”id” select=”id”/>
  <xsl:variable name=”url” select=”url”/>
  <span class=”srch-Icon”>
   <a href=”{$url}” id=”{concat(‘CSR_IMG_’,$id)}” title=”{$url}”>
   <img align=”absmiddle” src=”{webpage}” border=”0″ alt=”{webpage}” />
   </a>
  </span>


And we get these results: