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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

running a LOOP with custom 'incrementing' VAR


Go to End


2 Posts   1496 Views

Avatar
alex-solal

Community Member, 1 Post

21 November 2012 at 11:56pm

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

Forum Moderator, 5523 Posts

2 December 2012 at 5:58pm

You can the following template helpers

$Pos
$MultipleOf
$Modulus

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