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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Chunked output for loop


Go to End


3 Posts   603 Views

Avatar
dave.m

Community Member, 19 Posts

23 October 2014 at 4:50pm

I have a layout whereby I need to layout 2 rows of content:
Something like this
div
col1
col2
col3
col4
/div
div
col5
col6
col7
col8
/div

Is there a way to do this with SS templating?

TIA
Dave

Avatar
Devlin

Community Member, 344 Posts

23 October 2014 at 8:30pm

Edited: 23/10/2014 8:32pm

Either:

<div>
<% loop $Data.Limit(4,0) %>
$Name
<% end_loop %>
</div>
<div>
<% loop $Data.Limit(4,4) %>
$Name
<% end_loop %>
</div>

http://doc.silverstripe.org/framework/en/reference/templates#altering-the-list

Or:

<div>
<% loop $Data %>
$Name
<% if $MultipleOf(4) %>
</div><div>
<% end_if %>
<% end_loop %>
</div>

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

Avatar
dave.m

Community Member, 19 Posts

23 October 2014 at 8:40pm

Thanks Devlin, didnt notice it took an offset!