Customisation, Development, Technical
December 3, 2008

Customizing Search Series - Finally Customizing the Search Results



Enlarge Image

Written by: stevemann

Welcome to the sixth and final article in the Customizing Search Series. We will be finally customizing the actual search results. Everything that was done previously was all part of the overall search customization experience.

Perform a search within the Client scopes to bring up the Client Results page. Click on Site Actions and Edit Page. Edit the Search Core Results web part by clicking the Modify Shared Web Part from the Edit (dropdown) menu:

On the left hand side pane, under the Results Query Options, click inside the Selected Columns to make the blue ellipsis button appear. Click on the blue ellipsis button:

At the bottom of the text, before the </Columns> tag, add a column entry for each managed property that was created for the BDC content source:

Click OK.

Next click on the XSL Editor under the Data View Properties:

The XSL entry will appear in the text dialog.  It may be easier to copy and paste the code out into a different code editor and then paste back into the dialog for the remaining XSLT steps.

XSLT: Overriding the results URL

The tasks outlined in this section are for the scenario where we want to show a custom URL in the results versus the one returned from the normal search results. While this may not apply to everyone, the steps show how to add a new variable based on a custom search column and use it within the overall XSLT.

Locate the “This template is called for each result” section of the code.

Add a new variable name entry for the ClientURL under the two predefined variable entries (all variables should be in lowercase regardless of how the managed property was defined):

<xsl:variable name=”id” select=”id”/> <xsl:variable name=”url” select=”url”/><xsl:variable name=”clienturl” select=”clienturl”/>

Next, find and change all “$url” entries to “$clienturl”.

Find the “xsl:value-of select=”url”" entry within the hithighlightedproperties condition code (when statement). Change the “url” to “title”.

Locate the span class for srch-URL (span class=”srch-URL”). Within this section, locate the when condition for the hit highlighted properties as shown:

Replace the “hithighlightedproperties/HHUrl” with “clienturl”

Several lines down, replace the “url” in  “xsl:value-of select=”url”" with clienturl (xsl:value-of select=”clienturl”)

Click Save, Click OK on the web part tool pane and publish the page. The client search results should now show the custom client URL that is being returned from the BDC.

XSLT: Creating the Additional Reference Links within the Results

If you perform a Google search and you hit a website’s core address (such as Microsoft.com), there are additional reference links that appear within the search results:

You can add these to the MOSS Search results as well. The reference links can be displayed using standard HTML. This HTML should be placed after the “p class=”srch-Metadata” section (therefore after the p end-tag) :

The “ENTER THE HTML HERE” message will not appear - this was entered for demonstration purposes.

The following is sample code within a <div> block for rendering the additional link references. The appropriate URLs should be retrieved from the BDC and entered appropriately (the columns used here are generalurl, contacturl, documenturl, and referenceurl):

<div><table cols=”4″ cellspacing=”5″><tr>     <td></td>    <td>

<a href=”{$generalurl}” id=”{concat(’CSR_U_’,$id)}” title=”General Info” dir=”ltr”>Matters</a>

</td>

<td></td>

<td>

<a href=”{$contacturl}” id=”{concat(’CSR_U_’,$id)}” title=”Contact Information” dir=”ltr”>Contact Information</a>

</td>

</tr>

<tr>

<td></td>

<td>

<a href=”{$documenturl}” id=”{concat(’CSR_U_’,$id)}” title=”Documents” dir=”ltr”>Documents</a>

</td>

<td></td>

<td>

<a href=”{$referenceurl}” id=”{concat(’CSR_U_’,$id)}” title=”References” dir=”ltr”>References</a>

</td>

</tr>

<tr></tr>

<tr></tr>

</table>

</div>

Blank rows or cells are placed for spacing purposes. Additional URL properties will require additional variable entries as entered above (e.g. xsl:variable name=”generalurl” select=”generalurl”)

Here is a sample output:

Conclusion

We’ve done many things with the MOSS Search capabilities but obviously there are many more features and functionality. If you would like to see other search topics covered please send them along to mann@rdacorp.com.

This entry was posted on Wednesday, December 3rd, 2008 at 10:56 am and is filed under Customisation, Development, Technical. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
About the Author

Steve Mann

Mr. Mann is a Principal Architect at RDA Corporation with over 14 years of professional experience in the area of software development. He is involved with analysis, design, and development of integrated business solutions and systems utilizing Microsoft technologies and platforms.

Contact the author | Other Posts by stevemann (6) | Author's Website

 

Trackbacks

(Trackback URL)

close Reblog this comment
blog comments powered by Disqus


SharePoint Magazine

Support SharePoint Magazine

Technical

Everything You Need to Know about BDC: Part 3 of 8

Products

Visual Fusion Brings Location Intelligence to SharePoint

People

SharePoint Magazine chats with Paul Culmsee