You can do exactly that - in short, something like this will do:
<!-- Grab nodes from all over the place -->
<xsl:variable name="set1" select="..." />
<xsl:variable name="set2" select="..." />
<xsl:variable name="set3" select="..." />
<!-- Combine in one set and sort descending by created date -->
<xsl:for-each select="$set1 | $set2 | $set3">
<xsl:sort select="@createDate" data-type="text" order="descending" />
<!-- do stuff -->
</xsl:for-each>
Sort xslt from 6 different nodes
Hi,
I'm displaying my content from 6 different nodes. Here's the sample code. My problem is sorting it.
Is it possible to pull the data from the 6 different nodes and then store it in somehow temp variable so I can I sort it there accordingly?
Hi Sherry Ann,
You can do exactly that - in short, something like this will do:
<!-- Grab nodes from all over the place --> <xsl:variable name="set1" select="..." /> <xsl:variable name="set2" select="..." /> <xsl:variable name="set3" select="..." /> <!-- Combine in one set and sort descending by created date --> <xsl:for-each select="$set1 | $set2 | $set3"> <xsl:sort select="@createDate" data-type="text" order="descending" /> <!-- do stuff --> </xsl:for-each>/Chriztian
Hi Chriztian,
Since I have multiple sort order I'm trying to pass a variable on the sort statement.
I try this
and this
<xsl:sort select="{$sortBy}" data-type="text" order="{$sortType}" />
But both is not working. I just get a xslt error.
Hi Sherry Ann,
Yeah - unfortunately you're not allowed to use variables in the sort attributes - but here's a neat little trick that'll work:
<xsl:template match="/"> <xsl:variable name="sortBy" select="umbraco.library:RequestQueryString('sort')" /> <xsl:variable name="sortDir" select="umbraco.library:RequestQueryString('dir')" /> <xsl:for-each select="*"> <!-- Sorting using the "Mutually Exclusive" hack... --> <xsl:sort select="theatre[$sortBy = 'theatre' and $sortDir = 'asc']" data-type="text" order="ascending" /> <xsl:sort select="theatre[$sortBy = 'theatre' and $sortDir = 'desc']" data-type="text" order="descending" /> <xsl:sort select="datePlaying[$sortBy = 'date' and $sortDir = 'asc']" data-type="text" order="ascending" /> <xsl:sort select="datePlaying[$sortBy = 'date' and $sortDir = 'desc']" data-type="text" order="descending" /> <!-- do stuff --> </xsl:for-each> </xsl:template>/Chriztian
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.