Jump to:

3444 Posts in 1030 Topics by 871 members

Template Questions

SilverStripe Forums » Template Questions » running a LOOP with custom 'incrementing' VAR

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

Page: 1
Go to End
Author Topic: 368 Views
  • alex-solal
    Avatar
    Community Member
    1 Post

    running a LOOP with custom 'incrementing' VAR Link to this 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 ?

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: running a LOOP with custom 'incrementing' VAR Link to this post

    You can the following template helpers

    $Pos
    $MultipleOf
    $Modulus

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

    368 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.