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.


Discuss SilverStripe Themes.

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

Holder for childpages to create layout

Go to End

14 Posts   11348 Views


14 June 2011 at 10:39pm (Last edited: 15 June 2011 7:53am), Community Member, 15 Posts

Is it possible to create holder for subpages to output layout from subpages as they are? Example: you have subpage1 with 3 columns and subpage2 with 4 columns. Holder collects these to itself and outputs html page – first content and layout from subpage1 and under it subpage2 layout and content?

If this is possible, it gives an endless possibilities to create layout for one page, even some js-animation for revealing content from subpages. Or is this just a pointless idea?


18 June 2011 at 11:04pm (Last edited: 18 June 2011 11:05pm), Forum Moderator, 1091 Posts

Are you thinking on using different stylesheets only? Or different templates (as well)? And is this a holder page that would show content of multiple pages/pagetypes at the same time, all with their many different layouts? That would be somewhat complex... I suppose it can still be done, but doable? :-)


19 June 2011 at 5:24am Community Member, 15 Posts

Actually, stylesheets are the same, but child pages include different layout as columns. Columns are added in the administration view as column1 tab, column2 tab, and column3 tab. Templates uses 960gs and the final layouts are created with classes.

I think it should be a holder page that would show content of multiple pages/pagetypes at the same page (inside itself). How you "gurus" would start to figure this out? At the moment, I do not know where to start...


23 June 2011 at 12:11am Forum Moderator, 1091 Posts

Still thinking on this... :-)

If you were to know in advance what different layouts you were going to use, it's easy: you could use a conditional <% if .... %> <% elseif %> <% end_if %> in your <% control %> block that loops through the pages, and provide appropriate layouts...

Making it dynamice/extendable is a different thing:

- I don't think the <% include %> block accepts variables...

- you can't parse the template from a Controller function, since you have no access to controller methods from within the control block...

- You could consider parsing the template from a Datamodel function, but there you can't use RenderWith(), and having it return HTML would be no option I think...

- so now I think maybe you could use the Datamodel function above to instantiate a controller, and use a function within it to parse the appropriate template using RenderWith(). Never done that, but hey... :-)


23 June 2011 at 11:32am Google Summer of Code Hacker, 58 Posts

1) Just to be sure: We're talking about subpages in the CMS and not about inheritance here, right?

2) Isn't what you want or did I misunderstand your problem?


23 June 2011 at 6:36pm Community Member, 15 Posts

Could this picture illustrate it any... If we have a Product page on sitetree and child pages called product 1 (using page type 3column layout) and product 2 (using page type 4column layout) under Product page, I try to render these two child pages $Layout inside Product page. Product page should work dynamically and add new child page layouts after each other, based on CMS sitetree. Or I could use this technique to make pages scrollable on iPad, some kind of "content scroller", eh?

Attached Files

23 June 2011 at 10:03pm Forum Moderator, 1091 Posts

OK, maybe I was taking it a bit too far wanting to make it all dynamic and extendable, sorry for that :-)

Try a simple conditional in your template:

<% control Children %>
   <% if ClassName = PageType1 %>
      <!-- use some layout-->
   <% elseif ClassName = PageType2 %>
      <!-- use some other layout-->
   <% elseif ClassName = PageType3 %>
      <!-- yet another layout -->
   <% end_if %>
<% end_control %>


23 June 2011 at 10:18pm Google Summer of Code Hacker, 58 Posts

Yes martimiz, that's what I was thinking about. Not sure if it's flexible enough, but probably a good start...

Go to Top