Skip to content

Instantly share code, notes, and snippets.

@vgrem
Last active January 20, 2016 21:40
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/4773280 to your computer and use it in GitHub Desktop.
Save vgrem/4773280 to your computer and use it in GitHub Desktop.
Custom Sort Options for People Search Results
<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment