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.

Customising the CMS /

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

How to loop over Children/children SS Page Class


Go to End


1517 Views

Avatar
whjonker

Community Member, 12 Posts

10 February 2017 at 5:29am

Hi, I am currently working on a one page website. This website has as parent (HomePage), Children (ProductPage, AboutPage, ContactPage), Grand Children (Product DetailPage, AboutDetailPage)

Currently I would like to display the different ProductDetailPages on the ProductPage. This is done with:

In ProductPage.ss

<% loop $Children %>
<% loop $Children.Sort(ProductName, ASC) %>
<% include ProductDetailPage %>
<% end_loop %>
<% end_loop %>

This works perfectly fine, but I would to use the same approach for the AboutPage, but somehow the grandchildren from ProductPages are also being displayed.

In AboutPage.ss

<% loop $Children %>
<% loop $Children.Sort(AboutName, ASC) %>
<% include AboutDetailPage %>
<% end_loop %>
<% end_loop %>

I think the loops over all existing Grand children and displays them. I think I know I can resolve this by looping over a certain page class. Is this possible if so how can I do this? The option below does not seem to work.

<% loop $Children %>
<% loop $Children 'AboutPage'.Sort(AboutName, ASC) %>
<% include AboutDetailPage %>
<% end_loop %>
<% end_loop %>

Any help will be very appreciated :)

Thanks!