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

How do i create an if-statement with children


Go to End


3 Posts   1362 Views

Avatar
Suzanne

Community Member, 37 Posts

8 December 2012 at 3:09am

Hoi,

I want to make an news page looking like an newspaper with the first paragraphs of the child pages.

But I don't know how to get the child pages into the boxes, I need to give them a number so I decide in which box they
come

I put a screen with this question to let you see what I mean, and of course the code I justed.

Please can someone help me?

Gr. Suzanne

Attached Files
Avatar
Willr

Forum Moderator, 5523 Posts

8 December 2012 at 4:33pm

You cannot do <% if Children.isEen() %>.

Most of the time your boxes and pages will be in order so you could simply just do a <% loop Children %><div class="box">$Content.FirstParagraph</div><% end_if %> then float your boxes left. Your friends are $Pos, $MultipleOf and $Modulus which allow you to add classes or behaviour - http://doc.silverstripe.org/framework/en/reference/templates#looping-over-lists

Avatar
Suzanne

Community Member, 37 Posts

13 December 2012 at 2:55am

Thanks Willr, $Modulus works for me