Data Cogs Information Technology

posts - 135, comments - 152, trackbacks - 40

General

Search This Site

Powered by Google

Brisbane

Locations of visitors to this page

Archives

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:

posted on Friday, August 31, 2007 9:59 AM

Feedback

# re: Customizing MOSS Search Results - A couple of gotchas

Thanks for this,

Can you help me decipher which bit of the code does everything under the "line" ?e.g. {url} + author + write (modified date)

I want to replace this with values from some custom columns that are more relevant to this custom search

(tried doing this in SPD, but lost all the hit highlighing and could not really find a template that I liked)
9/11/2007 3:39 PM | Jason

Post Comment

Title  
Name  
Url
Comment   
Protected by Clearscreen.SharpHIPEnter the code you see: