Jump to:

23493 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Individual Sidebar for different Pages

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: 856 Views
  • StartUp3D
    Avatar
    Community Member
    10 Posts

    Individual Sidebar for different Pages Link to this post

    Hi there,
    like here: http://www.silverstripe.org/archive/show/117657 it try to use different sidebars for different Pages. I followed the example from the link, but unfortunately it´s not quite working. I´m able to choose in my admin-view the page i want to display in the sidebar, but no content is shown on the output-page.

    Here is my data i used:

    mysite/code/ContentPage.php

    class ContentPage extends Page
    {
       static $db = array();
       static $has_one = array(
          'RightSideBar' => 'Page'
       );
       
       function getCMSFields()
       {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab('Root.Content.Main', new TreeDropdownField("RightSideBar", "Rechte Sidebar anzeigen", "SiteTree"), 'Content');
          return $fields;
       }
    }
    class ContentPage_Controller extends Page_Controller {
       
    }

    mysite/code/RightSideBar.php

    class RightSideBar extends ContentPage
    {
       static $db = array();
       static $has_one = array();
    }

    class RightSideBar_Controller extends ContentPage_Controller
    {

    }

    templates/Layout/ContentPage.ss

    <div id="contentleft" style="width:500px;">
          $Content
    </div>
    <% control RightSideBar %>
       <div id="contentright" style="width:178px;">
          test: $Content
       </div>
    <% end_control %>

    Did I forgot something important?

    Thank you for your support.

    Best Greetings,
    Otto

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