3 users online. Create an account or sign in to join them.Users
[Solved] Xsl couter like php
This is an open discussion with 3 replies, filed under XSLT.
Search
use position() and a modulo-operator:
<xsl:for-each select="your-section/entry">
<div>
<xsl:if test="position() mod 2 = 0">
<xsl:attribute name="class">sap</xsl:attribute>
</xsl:if>
... the rest of your html ...
</div>
</xsl:for-each>
This gives each 2nd div the class ‘sap’.
Deleted
Thanks for the fast response, your code did exactly what i needed.
thank you.
Create an account or sign in to comment.
Hi, i´m very new to symphony, and so far i´m loving it, but i still can´t get php out of my head.
I´m trying to build a test site with symphony, on this site i have a products page, that lists a maximum of 10 products per page, i´m trying to place a separation div after avery row (wich holds 2 products each).
In php i would go something like :
$i = 0; foreach (product as record) { $i = 0 + 1; some html here } if ($i == 2) { echo '<div class="sap"></div>"; $i = 0; }But don´t know how to accomplish this in XLS, can anybody help?