Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
Hi,

Basically I want to loop through the entries and use some piece of HTML code (containing couch information) for the odd entries and another piece of HTML code (containing couch information) for the even entries.

I tried with the "zebra" tag but I think this is not really suitable.
Is there not something like :odd or :even like pseudo-elements? :?:

Thanks in advance...
Isn't there a way to check if things are dividable by 2? I think this would cover it otherwise (but % isnt supported...

Code: Select all
<cms:pages masterpage="fotos.php" include_subfolders='0' >
<cms:if k_count % '2'>
code snippet A
<cms:else />
code snippet B
</cms:if>
</cms:pages>
Modulo (%) is available with the 'mod' tag: docs/tags-reference/mod.html. You almost had it:
Code: Select all
<cms:pages masterpage='fotos.php' include_subfolders='0'>
    <cms:if "<cms:mod k_count '2'/>">
        Odd
    <cms:else/>
        Even
    </cms:if>
</cms:pages>
Thansk cheesyproof, will try...

This worked as well but the above seems more easy to the eyes.
Code: Select all
         <cms:pages masterpage="fotos.php" include_subfolders='0' >   
               <cms:php>
                 if (<cms:show k_count /> % 2 != 0)
                 {
                   echo 'snippet A';
                 }
                 else
                 {
                   echo 'snippet B';
                 }
               </cms:php>
            </cms:pages>      
         </div>
4 posts Page 1 of 1