DaCh
DaCh

Reputation: 931

umbraco xslt increment in foreach loop in foreach loop

im loop over some nodes, and then childs node of that current node. I wanna count each loop to set a id. theres from 1, 2, 3 and so on.

it's there a way to do this in xslt, like shown below

<xsl:for-each select="umbraco.library:GetXmlNodeById($node/partenId)">
    <div class="row filterHeader" data-id="id-{LoopCount}" >
    </div>
    <xsl:for-each select="./*">
          <div class="row filterHeader" data-id="id-{LoopCount}" >
          </div>
     </xsl:for-each>
</xsl:for-each>

So anyway to make "LoopCount" count itself up so there's only unique numbers in the right order?

as always, thanks for your time

Upvotes: 1

Views: 164

Answers (1)

Abel
Abel

Reputation: 57159

If all you need is a counter inside this loop, starting with 1, then you can suffice with replacing LoopCount with position(). If you need more, have a look at xsl:number.

<div class="row filterHeader" data-id="id-{position()}" >

Upvotes: 1

Related Questions