Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions

running a LOOP with custom 'incrementing' VAR


Reply

2 Posts   377 Views

Avatar
alex-solal

21 November 2012 at 11:56pm Community Member, 1 Post

Hi,

I've been using the $Modulus function in a (control loop) template to output:
---
<div class="column-1">
</div>

<div class="column-2">
</div>

<div class="column-3">
</div>
---

MY PROBLEM is - I'm using I need to output VIA <% control Children %> (I have 6 child pages, Im trying to output 3 columns per row)
<!--// ROW START -->
<div class="column-1-2">
1st child page
</div>

<div class="column-3-4">
2nd child page
</div>

<div class="column-5-6">
3rd child page
</div>
<!--// ROW END -->

THEN REPEAT
<!--// ROW START -->
<div class="column-1-2">
4th child page
</div>

<div class="column-3-4">
5th child page
</div>

<div class="column-5-6">
6th child page
</div>
<!--// ROW END -->

-----

Maybe I'm having a mental block - BUT I just cant seem to figure out how to write up the function in the controller...

ANYONE ?

Avatar
Willr

2 December 2012 at 5:58pm Forum Moderator, 5511 Posts

You can the following template helpers

$Pos
$MultipleOf
$Modulus

http://doc.silverstripe.org/framework/en/reference/templates#modulus-and-multipleof