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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Displaying Child Contents on a Parent Page


Go to End


8 Posts   2077 Views

Avatar
kerwei

Community Member, 5 Posts

20 September 2009 at 7:16am

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

Community Member, 545 Posts

20 September 2009 at 9:08am

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

Avatar
kerwei

Community Member, 5 Posts

21 September 2009 at 6:56am

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

Community Member, 164 Posts

21 September 2009 at 6:24pm

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

<% end_control %>

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

Avatar
kerwei

Community Member, 5 Posts

21 September 2009 at 8:43pm

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

Avatar
kerwei

Community Member, 5 Posts

22 September 2009 at 2:59am

*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

Community Member, 545 Posts

22 September 2009 at 3:14am

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

Community Member, 5 Posts

23 September 2009 at 3:47am

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