Can I Do This? As In VS2010 Its Being Highlighted As Invalid Syntax?
I want to be able to add a condition sort after a select depending on a Querystring value? But if I put an <xsl:if> or <xsl:choose> after the select it gets highlighted as invalid with the 'red death worms' under my syntax??
Yeah, it doesn't work because the sort has to be DIRECTLY after the for-each. The xsl:choose interferes with that. You should set some variables with the chosen sorting options first. I'll post an example in a minute.
Can I Do This? As In VS2010 Its Being Highlighted As Invalid Syntax?
I want to be able to add a condition sort after a select depending on a Querystring value? But if I put an <xsl:if> or <xsl:choose> after the select it gets highlighted as invalid with the 'red death worms' under my syntax??
<xsl:for-each select="$searchResults"> <xsl:choose> <xsl:when test="umbraco.library:Request('something') = 'something'"> <xsl:sort select="./data [@alias = 'this']" data-type="number" /> </xsl:when> <xsl:when test="umbraco.library:Request('something') = 'something'"> <xsl:sort select="./data [@alias = 'that']" data-type="number" /> </xsl:when> <xsl:otherwise> <xsl:sort select="./data [@alias = 'another']" data-type="number" /> </xsl:otherwise> </xsl:choose> </xsl:for-each>Yeah, it doesn't work because the sort has to be DIRECTLY after the for-each. The xsl:choose interferes with that. You should set some variables with the chosen sorting options first. I'll post an example in a minute.
Here's your code rewritten, something like this should work:
<xsl:choose> <xsl:when test="umbraco.library:Request('something') = 'something'"> <xsl:variable name="sortfield" select="./data [@alias = 'this']" /> </xsl:when> <xsl:when test="umbraco.library:Request('something') = 'something'"> <xsl:variable name="sortfield" select="./data [@alias = 'that']" /> </xsl:when> <xsl:otherwise> <xsl:variable name="sortfield" select="./data [@alias = 'another']" /> </xsl:otherwise> </xsl:choose> <xsl:call-template name="example"> <xsl:with-param name="item" select="."/> <xsl:with-param name="sortField" select="$sortField" /> </xsl:call-template>
Then, after the </xsl:template> item add a new template:
Actually, you probably don't need the seperate template, just put the for-each instead of the call-template bit. :)
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.