I have got multiple children which I display in a grid. 4 children fits in a row. Now I want to give every first and last children in a row an extra class to specify more styles. I tried:
<% if FirstInRow %>
<div class="gridContent firstInRow"></div>
<% else %>
<div class="gridContent"></div>
<% end_if %>
That’s the function:
function FirstInRow(){
return ($this->Pos(1) % 4 == 1) ? true : false;
}
You have the
ModulusandMultipleOfcontrols available to you in the template.http://doc.silverstripe.org/sapphire/en/reference/advanced-templates#modulus-and-multipleof