Jump to:

1383 Posts in 492 Topics by 521 members

Themes

SilverStripe Forums » Themes » Holder for childpages to create layout

Discuss SilverStripe Themes.

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

Page: 1 2
Go to End
Author Topic: 11295 Views
  • shrike
    Avatar
    Community Member
    15 Posts

    Holder for childpages to create layout Link to this post

    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?

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: Holder for childpages to create layout Link to this post

    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?

  • shrike
    Avatar
    Community Member
    15 Posts

    Re: Holder for childpages to create layout Link to this post

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

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: Holder for childpages to create layout Link to this post

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

  • xeraa
    Avatar
    Google Summer of Code Hacker
    58 Posts

    Re: Holder for childpages to create layout Link to this post

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

    2) Isn't http://doc.silverstripe.org/sapphire/en/reference/built-in-page-controls#and-lt-control-children-and-gt what you want or did I misunderstand your problem?

  • shrike
    Avatar
    Community Member
    15 Posts

    Re: Holder for childpages to create layout Link to this post

    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
  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: Holder for childpages to create layout Link to this post

    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 PageHolder.ss 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 %>

  • xeraa
    Avatar
    Google Summer of Code Hacker
    58 Posts

    Re: Holder for childpages to create layout Link to this post

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

    11295 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.