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
Hello friends I want to do is something like this:
<xsl:variable name="counter" select="1"/> <xsl:for-each select="$nodes"> <xsl:variable name="counter" select="$counter+1" /> </xsl:for-each><xsl:value-of select="$counter" />
I'm not sure what you really trying to do, but the snippet you've posted can be done with a single line using the count() function:
<xsl:value-of select="count($nodes) + 1" />
You almost never need to "just" count in XSLT, because you'll most likely be doing it based on the data available, for which you have a lot of tools available. Problem is, that it's a different way of thinking if you're very used to traditional "procedural" programming...
Let me know if your use case is more specific.
I want to get to have a counter of all the news, sports field that has the same soccer. Is this possible?
I guess maybe something like this:
<xsl:variable name="nodes" select="$currentPage//News" />
<xsl:variable name="soccerNews" select="$nodes[sport = 'soccer']" />
<xsl:variable name="count" select="count($soccerNews)" />
<xsl:value-of select="concat('We have ', $count, ' article')" />
<xsl:text> about soccer.</xsl:text>
Chriztian thank you very much, in the end I solved using Razor hehe first time I use it and I already did that fast eh! ejej Thank friend!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted