Jump to:

23370 Posts in 18145 Topics by 2864 members

General Questions

SilverStripe Forums » General Questions » loop children not returning any child

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

Page: 1
Go to End
Author Topic: 381 Views
  • michael_geeky
    Avatar
    Community Member
    10 Posts

    loop children not returning any child Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: loop children not returning any child Link to this post

    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

  • michael_geeky
    Avatar
    Community Member
    10 Posts

    Re: loop children not returning any child Link to this post

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

    381 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.