Customize the People Search Results – Part 2

In Customize the People Search Results – Part 1 we learned how to pimp the search results from looking something like this:

People Search Default Results

To something like this:

People Search New Results

In Part 2 we are going to learn how to add other fields (properties) to the Search results.

How do we do this?

Let’s first include the Mobile phone of a user into the XML list of results returned by the search service.

  • First you go to your People Search Page and execute a search on a certain name for wich you know you will find results.
  • On the results page you click on Site Actions / Edit page.
  • For the People Search Core Results web part you choose Modify Shared Web Part.

People Search Core Results Edit Web Part

  • Open the Results Query Options by pressing on the + sign in front of it.
  • Look up the Selected Columns field and press the [...] button and you’ll get this:
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Columns>
<Column Name="AccountName"/>
<Column Name="UserProfile_GUID"/>
<Column Name="PreferredName"/>
<Column Name="JobTitle"/>
<Column Name="Department"/>
<Column Name="WorkPhone"/>
<Column Name="OfficeNumber"/>
<Column Name="Fax"/>
<Column Name="AboutMe"/>
<Column Name="PictureURL"/>
<Column Name="WorkEmail"/>
<Column Name="WebSite"/>
<Column Name="Path"/>
<Column Name="HitHighlightedSummary"/>
<Column Name="HitHighlightedProperties"/>
<Column Name="Responsibility"/>
<Column Name="Skills"/>
<Column Name="SipAddress"/>
</Columns>
</root>
  • Now you’ll be able to include new columns based on the columns you can reference from the user profile database. For example if you wanted to include a person’s mobile phone you’ll want to include <Column Name=”MobilePhone”/>. After you’ve done that the XML getting returned by the Search has the MobilePhone column in it.
  • Where do you find these column names? Go to your Central Administration, click Shared Services, then Search Settings and click Metadata property mappings.

Meta Data Property Mappings

  • You’ll find the column names in the column Property Name.

Metadata Property Mobilephone

Now we’ll have to change the XSLT to include the MobilePhone column as output.

  • Choose Modify Shared Web Part for the People Search Core Results web part. If you don’t know how to do this look up a few lines.
  • Just below Data View Properties you see a XSL Editor button. Press it.
  • Search for “Phone” and you’ll find a line containing <xsl:with-param name=”phone” select=”workphone” />.
  • Copy that line and change the new line to <xsl:with-param name=”mobile” select=”mobilephone” />.
  • Keep searching for “Phone” and you’ll find the following line <xsl:param name=”phone” />.
  • Copy it and change the new line to <xsl:param name=”mobile” />.
  • Search again and you’ll find:
<xsl:if test='string-length($phone) > 0'>
<tr>
<td><b>Telefoon nr: </b></td>
<td><xsl:value-of select="$phone" />  </td>
</tr>
</xsl:if>
  • Copy and change to:
<xsl:if test='string-length($mobile) > 0'>
<tr>
<td><b>Mobiel nr: </b></td>
<td><xsl:value-of select="$mobile" />  </td>
</tr>
</xsl:if>
  • Save it, publish the page and retry your Person Search and you’ll get something like this:

People Search New Results Mobilephone

posted @ 2012-07-17 10:38  StarKong  阅读(231)  评论(0)    收藏  举报