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

Displaying Child Contents on a Parent Page


Reply

8 Posts   1562 Views

Avatar
kerwei

20 September 2009 at 7:16am Community Member, 5 Posts

Hi guys,

I'm new to website construction, and I need some help with an assignment I'm working on. I have created a Home Page, with a child page under it. This child page is not accessible from the menu and is hidden in search as well. My intention is to have the contents of this child page displayed in a small section on the left sidebar of the Home Page.

Can somebody please let me know how I can achieve this in the simplest way possible? Thanks in advance!

Avatar
zenmonkey

20 September 2009 at 9:08am Community Member, 528 Posts

<% control AllChildren %> can be used to access data from Children even if Show in Menus/Serach is off

Avatar
kerwei

21 September 2009 at 6:56am Community Member, 5 Posts

hi zenmonkey. thanks for the reply!

i would like to ask another question if you don't mind. if the HomePage has more than one child, how do i pick a specific child to be displayed instead of all of them?

Avatar
Bruce B

21 September 2009 at 6:24pm Community Member, 145 Posts

Try:
<% control Page(child-page-urlname) %>

<% end_control %>

where 'child-page-urlname' is the string from the page url.

Avatar
kerwei

21 September 2009 at 8:43pm Community Member, 5 Posts

doesn't work though. it returned a blank white page after i inserted those lines.

Avatar
kerwei

22 September 2009 at 2:59am Community Member, 5 Posts

*bump*

hi, guys. i'm still currently stuck with this. in fact this is the final piece of my website but i can't seem to get it working. tried the method by brucep but as i've reported, i got only a blank page in return after making the changes.

anybody has more suggestions on how i can get this done? thanks in advance again!

Avatar
zenmonkey

22 September 2009 at 3:14am Community Member, 528 Posts

Blank pages are usually calls to Bad Functions or ones that return bad data. Since the Child Control is built in you may either have the URL parameter written wrong or a problem with one of the Data Calls in the control. You could always structure the call in the template like

<% control AllChildren %>
<% if Title=x %>
Your Template Goes Here
<% end_if %>
<% end_control %>

Avatar
kerwei

23 September 2009 at 3:47am Community Member, 5 Posts

hi zenmonkey, that solved the problem! thank you so much! now i can finish the project. =)