Search

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?

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.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details