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.

Template Questions /

I don't understand "control ChildrenOf(page-url)"


Reply


5 Posts   1193 Views

Avatar
suntrop

Community Member, 131 Posts

21 May 2011 at 10:08pm

I want to display all product categories on my homepage (every category has its own thumbnail, that I want to display within a jQuery image scroller).

I think the …

<% control ChildrenOf(page-url) %>


… is the right function for that. But I don't know how to use it. This topic http://silverstripe.org/template-questions/show/9008 couldn't help.

What exactly do I have to enter for page-url? The web URI? The page type? Something else?

My site looks like this …
- Home
- Products
-- A
--- First product in category A
--- Second product in category A
-- B
--- First product in category B
--- Second product in category B
-- C
--- First product in category C
--- Second product in category C
- About us
- Contact

I'd like to display thumbnail for category A, B and C. But how? :-)

Hope someone can help.
Thanks
suntrop

Avatar
Willr

Forum Moderator, 5513 Posts

21 May 2011 at 10:57pm

What exactly do I have to enter for page-url? The web URI? The page type? Something else?

Perhaps page-url is a bad word, should be URLSegment. You pass in the URLSegment (viewable under each pages meta-data tab) that you want to control over. If your Products page has the URL Segment of "products" then you would use <% control ChildrenOf(products) %> if you want to use page type or classname you can write your own php method for that.

Avatar
suntrop

Community Member, 131 Posts

22 May 2011 at 5:43am

Thanks for your help, Willr.

The URL segment is products and I wrote …

<% control ChildrenOf(products) %>
<a href="$Link">$MenuTitle</a>
<% end_control %>

… just to test (with ?flush=1). But nothing happens. How do I access titles, links and the thumbnails?

Avatar
Willr

Forum Moderator, 5513 Posts

23 May 2011 at 9:30am

That should return a list of 'A','B','C' in your example. Check you have enabled 'Show In Menus' for those A,B,C pages and also check that the url segment is 'products'

Avatar
suntrop

Community Member, 131 Posts

25 May 2011 at 4:53am

Many many thanks for your help! :-)

I didn't checked "Show in Menus".

Is there any difference to the way of getting the products like some blog news (like in tutorial 2 extending a basic site)?