Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
What I'm trying to accomplish
<var name="sortOrder" />
<xsl:for-each>
<choose>
<when $sortOrder = 'something'>
<xsl:sort select=$sortOrder />
</when>
<otherwise>
<xsl:sort select='defaultVal' />
</otherwise>
</choose>
</xsl:foreach>
Sorry I've no idea on how to format code in this forum.. :/
In the old CWS package from Warren, he build something like this
<xsl:variable name="SortOrder" select="$currentPage/data [@alias = 'SortOrder']" /> <xsl:variable name="SortBy" select="$currentPage/data [@alias = 'SortBy']" />
Then he did some magic to determine the datatype
<!-- We need to set data-type to number or text depending on what sortby equals -->
<xsl:variable name="DataType">
<xsl:choose>
<xsl:when test="$SortBy='sortOrder'">
<xsl:value-of select="'number'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'text'" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
And finally the FOr each with conditional sort
<xsl:sort select="@*[name() = $SortBy]" order="{$SortOrder}" data-type="{$DataType}"/>
</ssl:for-each>
Hope this helps you,
Richard
Hello Chad to format code use the style dropdown box in the editor (where is says paragraph by deafult - hilight code and change to code)
<xsl:variable name="sortOrderQuerystring" select="umbraco.library:RequestQueryString('sortOrder')"/><xsl:variable name="sortOrder"> <xsl:choose> <xsl:when test="$sortOrderQuerystring = 'asc'"> <xsl:text>ascending</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>descending</xsl:text> </xsl:otherwise> </xsl:choose></xsl:variable><xsl:for-each select="you XPATH here"> <xsl:sort select="@nodeName" order="$sortOrder"/> <!-- Your for each loop here --></xsl:for each>
Still not having much luck here..
<xsl:sort select="@*[name() = $SortBy]" />
This is basically what im after, I want to sort by @nodeName by default, but if there's a querystring present, then I want it to sort by:
<xsl:sort select="./data [@alias = 'colourCode']" />
Having:
<xsl:sort select="@*[name() = 'colourCode]"
For instance... no dice :/
im having the same issues .. :-/
except im getting my data from SQL database with an XSLT extension ... and i need to sort it by querystring parameter .. :-/ ..
thinking it might be smarter to sort it in the SQL query ...?
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.
Continue discussion
Conditional xsl:sort
What I'm trying to accomplish
<var name="sortOrder" />
<xsl:for-each>
<choose>
<when $sortOrder = 'something'>
<xsl:sort select=$sortOrder />
</when>
<otherwise>
<xsl:sort select='defaultVal' />
</otherwise>
</choose>
</xsl:foreach>
Sorry I've no idea on how to format code in this forum.. :/
In the old CWS package from Warren, he build something like this
Then he did some magic to determine the datatype
<xsl:sort select="@*[name() = $SortBy]" order="{$SortOrder}" data-type="{$DataType}"/>Hope this helps you,
Richard
Hello Chad to format code use the style dropdown box in the editor (where is says paragraph by deafult - hilight code and change to code)
Still not having much luck here..
This is basically what im after, I want to sort by @nodeName by default, but if there's a querystring present, then I want it to sort by:
Having:
For instance... no dice :/
im having the same issues .. :-/
except im getting my data from SQL database with an XSLT extension ... and i need to sort it by querystring parameter .. :-/ ..
thinking it might be smarter to sort it in the SQL query ...?
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.