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 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

Layout in Layout

Go to End

4 Posts   1076 Views


Community Member, 96 Posts

24 October 2013 at 3:35am

Hey Guys,

I have a where my main layout sit. Then I have in the layout folder an, which is later placed in So far so easy.
Now I wanna go one level deeper: What I need is a as child from the The content from SubContentPage should be placed in ContentPage and ContentPage again in


<div class="Layout_from_ContentPage">
<div class="Content">$Layout_Layout</div>

And now I need something like this:

<div class="subcontent">$MyText</div>

At the end I want this structure:

  • StartPage

  • AboutMePage

  • ContentPage
    • SubContentPage1

    • SubContentPage2

    • SubContentPage3

I hope my description is clear. Is this possible?

Attached Files

Community Member, 254 Posts

24 October 2013 at 2:58pm

Inside your Page class you could add a function titled SubContent (or SubLayout). And return a rendered HTML block eg

		public function SubContent() {
			return $this->renderWith( 'Sub' . $this->class, array( 'Subcontent' => $this->SubSomeVarOrRelation ) );

Then inside your includes folder have & etc.
And either in your main or individual layout pages include the var $SubContent

The rendering will depend on how you're handling the SubContent. Are you just going to have an HTML field in the page, or are these going to be a list of DataObjects, or potentially one of many DataObjects.


Community Member, 96 Posts

25 October 2013 at 2:42am

Thank you for response. rendeWith works fine. But the pagetype from my SubContentPage needs to be ContentPage, doesn´t it?
In my case all Children of ContentPage must have another pagetype.


Community Member, 254 Posts

25 October 2013 at 11:36am

Might need some more info on how you're making the SubeContent? Can you paste some code?

If they're nested child pages you could make an include file in themes/templates/Includes/

And there loop over the children
<% loop Children %>
Render Sub Child Page stuff
<% end_loop %>

and then include it in your main page
<% if Children %>
<% end_if %>