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   440 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, 5513 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.