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

loop children not returning any child


Go to End


3 Posts   2328 Views

Avatar
michael_geeky

Community Member, 10 Posts

6 June 2013 at 7:13pm

Hi, I have a page type that allows another page type. similar to StaffHolder and StaffPage in the tute. But when I try using <% loop $Children %> inside the parent page template, it's not returning any of its child pages.

<% if $Children %>

<% loop $Children %>

<div>child</div>

<% end_loop %>

<% else %>

<div>No children found</div>

<% end_if %>

I am expecting 4 child divs displayed as I have 4 child pages belong to this current page. Currently it's just returning "No children found". I am not sure why. Can anyone give me some advice? It's really driving me crazy! (SS3)

Cheers,
Michael

Avatar
Willr

Forum Moderator, 5523 Posts

7 June 2013 at 10:29pm

Is the "ShowInMenus' tickbox ticked for those pages? Children is filtered by show in menus, to get all the children (without the filter) use AllChildren

Avatar
michael_geeky

Community Member, 10 Posts

10 June 2013 at 11:00pm

Thanks for referencing AllChildren(), Will. Yes, they aren't in the menu, I sorted it out by creating a controller action.