My modulos does not work as expected

Hi,

I have a list of event and I would like to print 2 event by line. As it does work, I simplfied my HTML and I tested the following into a CHUNK

[[+idx:mod:is=`1`:then=`<div class="row">`:else=``]]
<h4>[[+idx]] / [[+idx:mod:is=`1`]]</h4>
[[+idx:mod:is=`0`:then=`</div>`:else=``]]

My template contains the following

<section id="content" class="content">
	<div class="container well3">
             [[$evenementsTpl]]
        </div>
</section>

When I check my web page with w3c validator it return me

End tag section seen, but there were open elements.

If I clear my chuck (I romove the HTML code), w3c does not show any error. Then I suppose my chuck is not working properly

I am confuded because [[+idx:mod:is=1]] print either 1 or 0 (1,0,1,0,1,0,1,0 … etc)
[[+idx]] is incrementing from 1 to x

I wonder, we I have my mistake. Do I use correctly [[+idx:mod:is=1:then=

:else=``]] ?

Ha ok, I guess I just disciver the problem.
If I have an odd number of events, my row is not closed

Is there a way to know when is the last event? I could investigate on: “if the the modulos return 1 and is the last event => close the row”

What are you using to produce your list? Both getResources and pdoResources have &tplOdd properties. They also have &tplFirst and &tplLast properties.

It’s generally not a good practice to have separate
conditional statements that produce opening and closing tags and that depend on the number of data items you’re processing.

One way to go would be to have &tplFirst, &tplLast, and &tplOdd chunks that are identical except for the classes in the div tags they contain. That way you can use CSS to add different top and bottom margins that will space each div the way you want it to look regardless of how many there are.

With getResources, there is a placeholder [[+last]] available, that contains the index of the last row. There exists also a placeholder [[+odd]].
To combine the two placeholders you probably have to write a custom snippet.

Hello,
with &tplLast, I could fix my problem

[[+idx:mod:is=`1`:then=`<div class="row">`:else=``]]

<!--print event here-->

</div> <!-- need to be close what even is it a odd or a even -->

Until the number of rows changes by one. Then it breaks.