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.

General Questions

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

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

loop children not returning any child


Reply

3 Posts   433 Views

Avatar
michael_geeky

6 June 2013 at 7:13pm Community Member, 10 Posts

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

7 June 2013 at 10:29pm Forum Moderator, 5511 Posts

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

10 June 2013 at 11:00pm Community Member, 10 Posts

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