Created
June 23, 2011 13:58
-
-
Save nul800sebastiaan/1042579 to your computer and use it in GitHub Desktop.
Conditional sorting for XSLTSearch 1.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:choose> | |
<xsl:when test="umbraco.library:RequestQueryString('sortbydate') != ''"> | |
<xsl:for-each select="$matchedNodes"> | |
<!-- sort on the page score of the node, within ALL the nodes to return (the sorting must happen before choosing the nodes for this page) --> | |
<xsl:sort select="@createDate" order="descending"/> | |
<!-- only the nodes for this page --> | |
<xsl:if test="position() >= $startMatch and position() <= $endMatch"> | |
<xsl:call-template name="postlist" /> | |
</xsl:if> | |
<xsl:comment/> | |
</xsl:for-each> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:for-each select="$matchedNodes"> | |
<!-- sort on the page score of the node, within ALL the nodes to return (the sorting must happen before choosing the nodes for this page) --> | |
<xsl:sort select="substring-before(substring-after($pageScoreList, concat(';',generate-id(.),'=')),';')" data-type="number" order="descending"/> | |
<!-- only the nodes for this page --> | |
<xsl:if test="position() >= $startMatch and position() <= $endMatch"> | |
<xsl:call-template name="postlist" /> | |
</xsl:if> | |
<xsl:comment/> | |
</xsl:for-each> | |
</xsl:otherwise> | |
</xsl:choose> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem with this is that the first selects an attribute, whereas the other selects a string - you cannot put a predicate on a string, so you'd need to wrap that somehow...
Hmmm... edge-case...
/Chriztian