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
Hi,
I want to know how many items fit to my 'when ':
<xsl:variable name="count" select="1>
<
xsl:for-each select="$items">
<xsl:choose>
xsl:when test="somthing">
<xsl:variable name="count">
xsl:value-of select="$count+1"/>
</
xsl:variable>
</xsl:when>
</xsl:choose>
</xsl:for-each>
but when I do:
xsl:value-of select="$count"/> I get alwayse 1.
How can I get right number of items?
Thanks,
kukuwka
You can't change the values of variables in xslt. You might be able to use the count() function on a suitable node-set, where you have your "somthing" in the XPath expression.Regards,Magnus
use the position() function to know what iteration you are in ;)
I just explained it here: http://our.umbraco.org/forum/developers/xslt/13316-How-to-get-number-of-items-in-for-each
ps. don't double post ;)
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
Get count of items in for-each
Hi,
I want to know how many items fit to my 'when ':
<xsl:variable name="count" select="1>
<
xsl:for-each select="$items">
<xsl:choose>
<
xsl:when test="somthing">
<xsl:variable name="count">
<
xsl:value-of select="$count+1"/>
</
xsl:variable>
</xsl:when>
</xsl:choose>
</xsl:for-each>
but when I do:
<
xsl:value-of select="$count"/> I get alwayse 1.
How can I get right number of items?
Thanks,
kukuwka
You can't change the values of variables in xslt. You might be able to use the count() function on a suitable node-set, where you have your "somthing" in the XPath expression.
Regards,
Magnus
use the position() function to know what iteration you are in ;)
I just explained it here: http://our.umbraco.org/forum/developers/xslt/13316-How-to-get-number-of-items-in-for-each
ps. don't double post ;)
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.