Skip to content

Instantly share code, notes, and snippets.

@vgrem
Last active January 20, 2016 21:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgrem/4773309 to your computer and use it in GitHub Desktop.
Save vgrem/4773309 to your computer and use it in GitHub Desktop.
People Search Results with custom Sort Options
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
xmlns:asp="http://schemas.microsoft.com/ASPNET/20"
xmlns:SEARCHWC="http://schemas.microsoft.com/searchserver/">
<xsl:output method="xml" indent="no"/>
<xsl:param name="SortBy" />
<xsl:param name="DropDownOption" />
<xsl:param name="RelevanceSortUrl" />
<xsl:param name="RelevanceSortLabel" />
<xsl:param name="SocialDistanceSortUrl" />
<xsl:param name="SocialDistanceSortLabel" />
<xsl:param name="NameSortUrl" />
<xsl:param name="NameSortLabel" />
<xsl:param name="IsNoKeyword" />
<xsl:param name="IsFixedQuery" />
<xsl:param name="ShowMoreLink" />
<xsl:param name="MoreLinkLabel" />
<xsl:param name="MoreLink" />
<xsl:param name="AlertMeLink" />
<xsl:param name="AlertMeText" />
<xsl:param name="SrchRSSText" />
<xsl:param name="SrchRSSLink" />
<xsl:param name="ShowMessage" />
<xsl:param name="ShowActionLinks" />
<xsl:param name="SearchProviderText" />
<xsl:param name="SearchProviderLink" />
<xsl:param name="IsPeopleCoreResultsWebPart" />
<xsl:param name="NoFixedQuery" />
<xsl:param name="NoKeyword" />
<xsl:param name="NoPeopleResults" />
<xsl:param name="NoPeopleResults1" />
<xsl:param name="NoPeopleResults2" />
<xsl:param name="NoPeopleResults3" />
<xsl:param name="NoPeopleResults4" />
<xsl:param name="ParentOrgsLabel" />
<xsl:param name="ViewHiearchyLabel" />
<xsl:param name="RecentContentLabel" />
<xsl:param name="ResponsibilitiesLabel" />
<xsl:param name="SkillsLabel" />
<xsl:param name="InterestsLabel" />
<xsl:param name="PastProjectsLabel" />
<xsl:param name="SchoolLabel" />
<xsl:param name="MembershipLabel" />
<xsl:param name="AboutMeLabel" />
<xsl:param name="BaseOfficeLabel" />
<xsl:param name="SummaryLabel" />
<xsl:param name="ProfileViewLabel" />
<xsl:param name="UpdateProfileLabel" />
<xsl:param name="QueriesFoundYouLabel" />
<xsl:param name="UpdateProfileKeywordLabel" />
<xsl:param name="SelfSearchLabel" />
<xsl:param name="NoKeywordLabel" />
<xsl:param name="AddToMyColleaguesText" />
<xsl:param name="PopupFetcingResultLabel" />
<xsl:param name="IdPrefix" />
<xsl:param name="LangPickerHeading" />
<xsl:param name="LangPickerNodeSet" />
<xsl:param name="FilterNodeSet" />
<xsl:param name="ShowPeopleSortDropdown" />
<xsl:param name="RecentUpdateTabLabel" />
<!-- Custom Sorting parameters -->
<xsl:param name="CustomNameSortLabels" />
<xsl:param name="CustomNameSortValues" />
<xsl:param name="V1FromUrl" />
<xsl:param name="ViewByUrl" />
<xsl:param name="QueryFromUrl" />
<xsl:param name="HsFromUrl" />
<xsl:param name="RmFromUrl" />
<!-- When there is no keywory to issue the search -->
<xsl:template name="dvt_1.noKeyword">
<span class="ms-sbplain">
<xsl:choose>
<xsl:when test="$IsFixedQuery">
<xsl:value-of select="$NoFixedQuery" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$NoKeyword" />
</xsl:otherwise>
</xsl:choose>
</span>
</xsl:template>
<!-- When empty result set is returned from search -->
<xsl:template name="dvt_1.empty">
<div class="psrch-results">
<xsl:if test="$ShowActionLinks">
<xsl:call-template name="ActionBarTemplate" />
</xsl:if>
</div>
<span class="srch-description" id="CSR_NO_RESULTS">
<xsl:value-of select="$NoPeopleResults"/>
<ol>
<li>
<xsl:value-of select="$NoPeopleResults1"/>
</li>
<li>
<xsl:value-of select="$NoPeopleResults2"/>
</li>
<li>
<xsl:value-of select="$NoPeopleResults3"/>
</li>
<li>
<xsl:value-of select="$NoPeopleResults4"/>
</li>
</ol>
</span>
</xsl:template>
<!-- Main body template-->
<xsl:template name="dvt_1.body">
<div class="psrch-results">
<xsl:if test="$ShowActionLinks">
<div class="srch-sort-right2">
<xsl:if test="$LangPickerNodeSet and count($LangPickerNodeSet) &gt; 0">
<label for="langpickerdd" id="langpickerddlabel">
<xsl:value-of select="$LangPickerHeading"/>
</label>
<select title="{$LangPickerHeading}" class="srch-dropdown" onchange="window.location.href=this.value" id="langpickerdd">
<xsl:for-each select="$LangPickerNodeSet">
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="@url"/>
</xsl:attribute>
<xsl:if test="@selected = 'true'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="@title"/>
</xsl:element>
</xsl:for-each>
</select>
<xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
</xsl:if>
<xsl:if test="$ShowPeopleSortDropdown">
<label for="sortbydd" id="sortbyddlabel">
<xsl:value-of select="$SortBy" />
</label>
<select title="{$SortBy}" name="dropdown" onchange="window.location.href=this.value" class="srch-dropdown" id="sortbydd">
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="ddwrt:EnsureAllowedProtocol(string($RelevanceSortUrl))"/>
</xsl:attribute>
<xsl:if test="$DropDownOption = '0'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="$RelevanceSortLabel"/>
</xsl:element>
<xsl:if test="string-length($SocialDistanceSortUrl) &gt; 0 and string-length($SocialDistanceSortLabel) &gt; 0">
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="ddwrt:EnsureAllowedProtocol(string($SocialDistanceSortUrl))"/>
</xsl:attribute>
<xsl:if test="$DropDownOption = '1'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="$SocialDistanceSortLabel"/>
</xsl:element>
</xsl:if>
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="ddwrt:EnsureAllowedProtocol(string($NameSortUrl))"/>
</xsl:attribute>
<xsl:if test="$DropDownOption = '2'">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="$NameSortLabel"/>
</xsl:element>
<!-- Custom Sort options goes here -->
<xsl:call-template name="CustomSortOptions"/>
</select>
<xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
</xsl:if>
<xsl:call-template name="ActionBarTemplate" />
</div>
</xsl:if>
<xsl:for-each select="All_Results/Result">
<xsl:sort data-type="text" order="ascending" select="*[name() = $V1FromUrl]"/>
<xsl:call-template name="SingleResult"/>
</xsl:for-each>
<xsl:call-template name="MoreLinkTemplate" />
</div>
</xsl:template>
<xsl:template name="GetCustomSortResultUrl">
<xsl:param name="NameSortValue"/>
<xsl:value-of select="concat(concat(concat('peopleresults.aspx?k=',$QueryFromUrl),'&amp;v1='),$NameSortValue)"/>
</xsl:template>
<xsl:template name="CustomSortOptions">
<xsl:param name="NameSortValues" select="$CustomNameSortValues"/>
<xsl:param name="NameSortLabels" select="$CustomNameSortLabels"/>
<xsl:param name="separator" select="','"/>
<xsl:choose>
<xsl:when test="not(contains($NameSortValues, $separator))">
<xsl:if test="string-length($NameSortValues) &gt; 0">
<xsl:variable name="NameSortUrl">
<xsl:call-template name="GetCustomSortResultUrl">
<xsl:with-param name="NameSortValue" select="$NameSortValues"/>
</xsl:call-template>
</xsl:variable>
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="ddwrt:EnsureAllowedProtocol(string($NameSortUrl))"/>
</xsl:attribute>
<xsl:if test="$NameSortValues = $V1FromUrl and string-length($HsFromUrl) = 0">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="$NameSortLabels"/>
</xsl:element>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="NameSortUrl">
<xsl:call-template name="GetCustomSortResultUrl">
<xsl:with-param name="NameSortValue" select="substring-before($NameSortValues, $separator)"/>
</xsl:call-template>
</xsl:variable>
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="ddwrt:EnsureAllowedProtocol(string($NameSortUrl))"/>
</xsl:attribute>
<xsl:if test="substring-before($NameSortValues, $separator) = $V1FromUrl">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="substring-before($NameSortLabels, $separator)"/>
</xsl:element>
<xsl:call-template name="CustomSortOptions">
<xsl:with-param name="NameSortValues" select="substring-after($NameSortValues, $separator)"/>
<xsl:with-param name="NameSortLabels" select="substring-after($NameSortLabels, $separator)"/>
<xsl:with-param name="separator" select="','"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- This template is called for each result -->
<xsl:template name="SingleResult">
<xsl:element name="div">
<xsl:attribute name="id">
<xsl:value-of select="concat('Container', id)"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="id = 1">
<xsl:attribute name="class">psrch-FirstFullResult</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">psrch-FullResult</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="SingleResultInternal" />
</xsl:element>
</xsl:template>
<xsl:template name="SingleResultInternal">
<xsl:variable name="id" select="id"/>
<xsl:variable name="currentId" select="concat($IdPrefix,$id)"/>
<xsl:variable name="url" select="url"/>
<xsl:variable name="email" select="workemail"/>
<xsl:variable name="sip" select="sipaddress"/>
<xsl:variable name="prefix">IMNRC('</xsl:variable>
<xsl:variable name="suffix">')</xsl:variable>
<xsl:variable name="hassip" select="string-length($sip) &gt; 0"/>
<xsl:variable name="hasemail" select="string-length($email) &gt; 0"/>
<xsl:variable name="haspn" select="string-length(preferredname) &gt; 0"/>
<xsl:variable name="hasydn" select="string-length(yomidisplayname) &gt; 0"/>
<xsl:variable name="hasjt" select="string-length(jobtitle) &gt; 0"/>
<xsl:variable name="hasdp" select="string-length(department) &gt; 0"/>
<xsl:variable name="hasorg" select="string-length(orgnames) &gt; 0"/>
<xsl:variable name="haswph" select="string-length(workphone) &gt; 0"/>
<xsl:variable name="hasonum" select="string-length(officenumber) &gt; 0"/>
<xsl:variable name="hascol" select="string-length(colleaguecategory) &gt; 0"/>
<xsl:variable name="hasacu" select="string-length(addtomycolleaguesurl) &gt; 0"/>
<xsl:variable name="hashier" select="string-length(hierarchyurl) &gt; 0"/>
<xsl:variable name="hasabme" select="string-length(aboutme) &gt; 0"/>
<xsl:variable name="hasresp" select="string-length(responsibility) &gt; 0"/>
<xsl:variable name="hassk" select="($FilterNodeSet and $FilterNodeSet/@title='SPShSkills') or hithighlightedproperties/skills/@hashh &gt; 0"/>
<xsl:variable name="hasint" select="($FilterNodeSet and $FilterNodeSet/@title='SPShInterests') or hithighlightedproperties/interests/@hashh &gt; 0"/>
<xsl:variable name="hasorgparent" select="($FilterNodeSet and $FilterNodeSet/@title='OrgParentNames') or hithighlightedproperties/orgparentnames/@hashh &gt; 0"/>
<xsl:variable name="hasmem" select="($FilterNodeSet and $FilterNodeSet/@title='Memberships') or hithighlightedproperties/memberships/@hashh &gt; 0"/>
<xsl:variable name="haspp" select="($FilterNodeSet and $FilterNodeSet/@title='SPShPastProjects') or hithighlightedproperties/pastprojects/@hashh &gt; 0"/>
<xsl:variable name="hasbol" select="($FilterNodeSet and $FilterNodeSet/@title='SPShLocation') or hithighlightedproperties/baseofficelocation/@hashh &gt; 0"/>
<xsl:variable name="hassch" select="($FilterNodeSet and $FilterNodeSet/@title='SPShSchool') or hithighlightedproperties/schools/@hashh &gt; 0"/>
<xsl:variable name="hassum" select="count(hithighlightedsummary/c0) &gt; 0"/>
<xsl:variable name="hasvlm" select="string-length(profileviewlastmonth) &gt; 0"/>
<xsl:variable name="hasvlw" select="string-length(profileviewlastweek) &gt; 0"/>
<xsl:variable name="hasquery" select="string-length(queriesfoundyou) &gt; 0"/>
<div id="UserPhoto">
<a href="{ddwrt:EnsureAllowedProtocol(string($url))}" id="{concat($currentId, '_CSR_IMGL')}" title="{preferredname}">
<xsl:variable name="imgid" select="concat('CSR_IMG_',$id)"/>
<xsl:variable name="purl">
<xsl:call-template name="GetPicUrl">
<xsl:with-param name="PicUrl" select="pictureurl"/>
<xsl:with-param name="PlaceHolderUrl" select="'/_layouts/images/o14_person_placeholder_96.png'"/>
</xsl:call-template>
</xsl:variable>
<img id="{$imgid}" src="{ddwrt:EnsureAllowedProtocol(string($purl))}" alt="{preferredname}" border="0"></img>
</a>
<xsl:if test="$hascol">
<div id="ColleagueField">
<xsl:value-of select="colleaguecategory"/>
</div>
</xsl:if>
</div>
<span id="JBean">
<xsl:choose>
<xsl:when test="$hassip">
<img alt="" border="0" height="12" width="12" src="/_layouts/images/imnhdr.gif" onload="{concat($prefix, $sip, $suffix)}" ShowOfflinePawn="1" id="{concat('CSRP_',$id,',type=sip')}" />
</xsl:when>
<xsl:otherwise>
<img alt="" border="0" height="12" width="12" src="/_layouts/images/imnhdr.gif" onload="{concat($prefix, $email, $suffix)}" ShowOfflinePawn="1" id="{concat('CSRP_',$id,',type=smtp')}" />
</xsl:otherwise>
</xsl:choose>
</span>
<div id="ContactInfo">
<ul id="MiniContactCard">
<li id="NameField">
<xsl:if test="$haspn">
<a href="{ddwrt:EnsureAllowedProtocol(string($url))}" id="{concat($currentId, '_CSR')}">
<xsl:apply-templates select="hithighlightedproperties/preferredname" />
</a>
</xsl:if>
</li>
<xsl:if test="$hasydn">
<li id="YomiField">
<xsl:apply-templates select="hithighlightedproperties/yomidisplayname" />
</li>
</xsl:if>
<xsl:if test="$hasjt">
<li id="JobTitleField">
<xsl:apply-templates select="hithighlightedproperties/jobtitle" />
</li>
</xsl:if>
<xsl:if test="$hasdp and not($hasorg)">
<li id="DepartmentField">
<xsl:apply-templates select="hithighlightedproperties/department" />
</li>
</xsl:if>
<xsl:if test="$hasorg">
<li id="OrgField">
<xsl:call-template name="RenderNameUrlMultivalue">
<xsl:with-param name="names" select="hithighlightedproperties/orgnames"/>
<xsl:with-param name="urls" select="orgurls_multival"/>
<xsl:with-param name="currentId" select="$currentId"/>
</xsl:call-template>
</li>
</xsl:if>
<xsl:if test="$haswph">
<li id="PhoneField">
<xsl:apply-templates select="hithighlightedproperties/workphone" />
</li>
</xsl:if>
<xsl:if test="$hasonum">
<li id="OfficeField">
<xsl:apply-templates select="hithighlightedproperties/officenumber" />
</li>
</xsl:if>
<xsl:if test="$hassip or $hasemail">
<li id="EmailField">
<xsl:choose>
<xsl:when test="$hassip">
<a id="{concat($currentId, '_EmailLink')}" href="{concat('mailto:', $sip)}">
<xsl:apply-templates select="hithighlightedproperties/sipaddress" />
</a>
</xsl:when>
<xsl:otherwise>
<a id="{concat($currentId, '_EmailLink')}" href="{concat('mailto:', $email)}">
<xsl:apply-templates select="hithighlightedproperties/workemail" />
</a>
</xsl:otherwise>
</xsl:choose>
</li>
</xsl:if>
</ul>
<xsl:if test="$hasacu or $hashier or $IsPeopleCoreResultsWebPart">
<ul id="Actions">
<xsl:if test="$hasacu">
<li id="AddColleagueLinkField">
<a id="{concat($currentId, '_AddColleagueLink')}" href="{ddwrt:EnsureAllowedProtocol(string(addtomycolleaguesurl))}">
&#187; <xsl:value-of select="$AddToMyColleaguesText" />
</a>
</li>
</xsl:if>
<xsl:if test="$hashier">
<li id="OrgBrowserField">
<a id="{concat($currentId, '_OrgBrowserLink')}" href="{ddwrt:EnsureAllowedProtocol(string(hierarchyurl))}">
&#187; <xsl:value-of select="$ViewHiearchyLabel" />
</a>
</li>
</xsl:if>
<xsl:if test="$IsPeopleCoreResultsWebPart">
<li id="RecentContentField">
<a href="javascript:" ID="{concat('recentcontentlink_',$id)}" runat="server" PreferredName="{preferredname}">
<xsl:value-of select="concat('&#187; ', substring-before($RecentContentLabel, '{0}'), preferredname, substring-after($RecentContentLabel, '{0}'))"/>
</a>
<SEARCHWC:PopupControlExtender ID="{concat('popupextender_',$id)}" runat="server"
TargetControlID="{concat('recentcontentlink_',$id)}"
PopupControlID="PopupPanelPeopleCore"
PopupShowingScript="{concat('PostbackUserName(this.get_element(),this._popupElement,&quot;',$RecentUpdateTabLabel,'&quot;)')}"
PopupHiddenScript=""
HoverDelay="500"
UnhoverDelay="500"/>
</li>
</xsl:if>
</ul>
</xsl:if>
</div>
<xsl:if test="$hasabme or $hasresp or $hassk or $hasint or $hasorgparent or $hasmem or $haspp or $hassch or $hasbol or $hassum">
<div id="MoreInfo">
<ul>
<xsl:if test="$hasabme">
<li>
<span id="FieldTitle">
<xsl:value-of select="$AboutMeLabel" />
</span>
<xsl:apply-templates select="hithighlightedproperties/aboutme" />
</li>
</xsl:if>
<xsl:if test="$hasresp">
<li>
<span id="FieldTitle">
<xsl:value-of select="$ResponsibilitiesLabel" />
</span>
<xsl:call-template name="RenderSimpleMultivalue">
<xsl:with-param name="multivalue" select="hithighlightedproperties/responsibility"/>
<xsl:with-param name="cutoff" select="5"/>
</xsl:call-template>
</li>
</xsl:if>
<xsl:if test="$hassk">
<li>
<span id="FieldTitle">
<xsl:value-of select="$SkillsLabel" />
</span>
<xsl:call-template name="RenderSimpleMultivalue">
<xsl:with-param name="multivalue" select="hithighlightedproperties/skills"/>
<xsl:with-param name="cutoff" select="5"/>
</xsl:call-template>
</li>
</xsl:if>
<xsl:if test="$hasint">
<li>
<span id="FieldTitle">
<xsl:value-of select="$InterestsLabel" />
</span>
<xsl:call-template name="RenderSimpleMultivalue">
<xsl:with-param name="multivalue" select="hithighlightedproperties/interests"/>
<xsl:with-param name="cutoff" select="5"/>
</xsl:call-template>
</li>
</xsl:if>
<xsl:if test="$hasorgparent">
<li>
<span id="FieldTitle">
<xsl:value-of select="$ParentOrgsLabel" />
</span>
<span id="HotHH">
<xsl:call-template name="RenderNameUrlMultivalue">
<xsl:with-param name="names" select="hithighlightedproperties/orgparentnames"/>
<xsl:with-param name="urls" select="orgparenturls_multival"/>
<xsl:with-param name="currentId" select="$currentId"/>
</xsl:call-template>
</span>
</li>
</xsl:if>
<xsl:if test="$hasmem">
<li>
<span id="FieldTitle">
<xsl:value-of select="$MembershipLabel" />
</span>
<xsl:call-template name="RenderSimpleMultivalue">
<xsl:with-param name="multivalue" select="hithighlightedproperties/memberships"/>
<xsl:with-param name="cutoff" select="5"/>
</xsl:call-template>
</li>
</xsl:if>
<xsl:if test="$haspp">
<li>
<span id="FieldTitle">
<xsl:value-of select="$PastProjectsLabel" />
</span>
<xsl:call-template name="RenderSimpleMultivalue">
<xsl:with-param name="multivalue" select="hithighlightedproperties/pastprojects"/>
<xsl:with-param name="cutoff" select="5"/>
</xsl:call-template>
</li>
</xsl:if>
<xsl:if test="$hassch">
<li>
<span id="FieldTitle">
<xsl:value-of select="$SchoolLabel" />
</span>
<xsl:call-template name="RenderSimpleMultivalue">
<xsl:with-param name="multivalue" select="hithighlightedproperties/schools"/>
<xsl:with-param name="cutoff" select="5"/>
</xsl:call-template>
</li>
</xsl:if>
<xsl:if test="$hasbol">
<li>
<span id="FieldTitle">
<xsl:value-of select="$BaseOfficeLabel" />
</span>
<xsl:apply-templates select="hithighlightedproperties/baseofficelocation" />
</li>
</xsl:if>
<xsl:if test="$hassum">
<li>
<span id="FieldTitle">
<xsl:value-of select="$SummaryLabel" />
</span>
<xsl:apply-templates select="hithighlightedsummary" />
</li>
</xsl:if>
</ul>
</div>
</xsl:if>
<div id="Clear">
<img src='/_layouts/images/blank.gif' alt=''/>
</div>
<xsl:if test="$hasvlm or $hasvlw or $hasquery">
<div id="SelfSrchHeading">
<table cellspacing="0" cellpadding="0">
<tr>
<td>
<xsl:value-of select="$SelfSearchLabel" />
</td>
</tr>
</table>
</div>
<div id="SelfSrchFreq">
<a id="{concat($currentId, '_EditProfileLink')}" href="{ddwrt:EnsureAllowedProtocol(string(editprofileurl))}">
<xsl:value-of select="$UpdateProfileLabel" />
</a>
<div id="SelfSrchFreqTitle">
<xsl:value-of select="$ProfileViewLabel" />
</div>
<xsl:if test="$hasvlm and $hasvlw">
<ul>
<li>
<xsl:value-of disable-output-escaping="yes" select="profileviewlastmonth"/>
</li>
<li>
<xsl:value-of disable-output-escaping="yes" select="profileviewlastweek"/>
</li>
</ul>
</xsl:if>
</div>
<div id="SelfSrchTerms">
<a id="{concat($currentId, '_UpdateKeywordsLink')}" href="{ddwrt:EnsureAllowedProtocol(string(updatekeywordsurl))}">
<xsl:value-of select="$UpdateProfileKeywordLabel" />
</a>
<div id="SelfSrchTermsTitle">
<xsl:value-of select="$QueriesFoundYouLabel" />
</div>
<div id="SelfSrchTermsContent">
<xsl:choose>
<xsl:when test="$hasquery">
<xsl:call-template name="RenderSimpleMultivalue">
<xsl:with-param name="multivalue" select="queriesfoundyou_multival"/>
<xsl:with-param name="cutoff" select="5"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$NoKeywordLabel" />
</xsl:otherwise>
</xsl:choose>
</div>
</div>
<div id="Clear2">
<img src='/_layouts/images/blank.gif' alt=''/>
</div>
</xsl:if>
</xsl:template>
<!-- XSL transformation starts here -->
<xsl:template match="/">
<xsl:if test="$AlertMeLink and $ShowActionLinks">
<input type="hidden" name="P_Query" />
<input type="hidden" name="P_LastNotificationTime" />
</xsl:if>
<div class="psrch-Main">
<xsl:choose>
<xsl:when test="$IsNoKeyword = 'True'" >
<xsl:call-template name="dvt_1.noKeyword" />
</xsl:when>
<xsl:when test="$ShowMessage = 'True'">
<xsl:call-template name="dvt_1.empty" />
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="dvt_1.body"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$IsPeopleCoreResultsWebPart and (count(All_Results/Result) &gt; 0 or count(All_Results/FakeResult) &gt; 0)">
<asp:Panel ID="PopupPanelPeopleCore" runat="server" CssClass="psrch-PopupPanel">
<div id="PopupContainer" class="psrch-PopupContainer">
<asp:UpdatePanel runat="server" ID="UpdatePanelPeopleCore" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<SEARCHWC:PeopleCoreResultPopupControl
id="PopupControl51A944753DF0430C8FE1EBAA70F3E945"
runat="server"/>
<div id="PopupFooter">
<asp:UpdateProgress ID="UpdateProgress" DisplayAfter="0" AssociatedUpdatePanelID="UpdatePanelPeopleCore" runat="server">
<ProgressTemplate>
<span id="Progress">
<img class="psrch-UpdateGraphics" src="/_layouts/images/hig_progcircle_loading24.gif"/>
<xsl:value-of select="$PopupFetcingResultLabel" />
</span>
</ProgressTemplate>
</asp:UpdateProgress>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Panel>
</xsl:if>
</div>
</xsl:template>
<xsl:template name="ActionBarTemplate">
<xsl:if test="string-length($AlertMeLink) &gt; 0">
<a href="{$AlertMeLink}" id="CSR_AM" title="{$AlertMeText}">
<img src="/_layouts/images/bell.gif" alt="{$AlertMeText}" border="0"/>
</a>
<xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
</xsl:if>
<xsl:if test="string-length($SrchRSSLink) &gt; 0">
<a type="application/rss+xml" href="{ddwrt:EnsureAllowedProtocol(string($SrchRSSLink))}" title="{$SrchRSSText}" id="SRCHRSSL">
<img border="0" src="/_layouts/images/rss.gif" alt="{$SrchRSSText}"/>
</a>
<xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
</xsl:if>
<xsl:if test="string-length($SearchProviderLink) &gt; 0">
<a href="{ddwrt:EnsureAllowedProtocol(string($SearchProviderLink))}" title="{$SearchProviderText}" >
<img border="0" src="/_layouts/images/searchfolder.png" alt="{$SearchProviderText}"/>
</a>
<xsl:text disable-output-escaping="yes">&#8195;</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="GetPicUrl">
<xsl:param name="PicUrl"/>
<xsl:param name="PlaceHolderUrl"/>
<xsl:choose>
<xsl:when test="string-length($PicUrl) &lt; 1 or starts-with($PicUrl, 'file:') or starts-with($PicUrl, '\\') or starts-with($PicUrl, '//')">
<xsl:value-of select="$PlaceHolderUrl"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$PicUrl"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="MoreLinkTemplate">
<xsl:if test="$ShowMoreLink = true() and string-length($MoreLink) &gt; 0">
<div id="MoreLink">
<a href="{ddwrt:EnsureAllowedProtocol(string($MoreLink))}">
<xsl:value-of select="$MoreLinkLabel"/>
</a>
</div>
</xsl:if>
</xsl:template>
<xsl:template name="RenderNameUrlMultivalue">
<xsl:param name="names"/>
<xsl:param name="urls"/>
<xsl:param name="currentId"/>
<xsl:for-each select="$names">
<xsl:variable name="p" select="position()"/>
<xsl:if test="string-length(.) &gt; 0">
<xsl:if test="$p &gt; 1">
<span class="psrch-TextSeparator"> :: </span>
</xsl:if>
<xsl:choose>
<xsl:when test="string-length($urls[$p]) &gt; 0">
<a id="{concat($currentId, '_MultivalueUrl')}" href="{ddwrt:EnsureAllowedProtocol(string($urls[$p]))}">
<xsl:apply-templates select="." />
</a>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="RenderSimpleMultivalue">
<xsl:param name="multivalue"/>
<xsl:param name="cutoff"/>
<xsl:for-each select="$multivalue">
<xsl:sort data-type="number" order="descending" select="@hashh"/>
<xsl:variable name="p" select="position()"/>
<xsl:if test="string-length(.) &gt; 0">
<xsl:choose>
<xsl:when test="$p = 1">
<span id="Multivalue">
<xsl:apply-templates select="." />
</span>
</xsl:when>
<xsl:when test="$p &gt; 1 and $p &lt;= $cutoff">
<span class="psrch-TextSeparator"> :: </span>
<span id="Multivalue">
<xsl:apply-templates select="." />
</span>
</xsl:when>
<xsl:when test="$p = $cutoff + 1">
&#8230;
</xsl:when>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="HitHighlighting">
<xsl:param name="hh" />
<xsl:apply-templates select="$hh"/>
</xsl:template>
<xsl:template match="ddd">
&#8230;
</xsl:template>
<xsl:template match="c0">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c1">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c2">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c3">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c4">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c5">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c6">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c7">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c8">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
<xsl:template match="c9">
<b>
<xsl:value-of select="."/>
</b>
</xsl:template>
</xsl:stylesheet>
@vgrem
Copy link
Author

vgrem commented Feb 25, 2013

Hi,

please follow my blog post that describes XSLT based approach for sorting People Search Results web part here http://vgrem.wordpress.com/2013/02/26/customizing-search-results-sharepoint-2010-people-search-results-custom-sorting-using-xslt/

Note: XSLT for People Search Results has been updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment