Jump to:

23551 Posts in 19348 Topics by 2891 members

General Questions

SilverStripe Forums » General Questions » Layout in Layout

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

Page: 1
Go to End
Author Topic: 273 Views
  • Bereusei
    Community Member
    94 Posts

    Layout in Layout Link to this post

    Hey Guys,

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




    <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
  • Bambii7
    Community Member
    254 Posts

    Re: Layout in Layout Link to this post

    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 SubPage.ss & SubContactPage.ss etc.
    And either in your main Page.ss 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.

  • Bereusei
    Community Member
    94 Posts

    Re: Layout in Layout Link to this post

    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.

  • Bambii7
    Community Member
    254 Posts

    Re: Layout in Layout Link to this post

    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/RenderChildren.ss

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

Page: 1
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.