Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » two widgetareas for a page

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: 965 Views
  • Nivanka
    Community Member
    395 Posts

    two widgetareas for a page Link to this post

    I need to have two sidebars, and two widgetareas for them.

    but when I add the two WidgetAreaEditors, the second WidgetAreaEditor doesn't work. I just try to check what has happened and I found that both the WidgetAreaEditors use the same ID WidgetAreaEditor_availableWidgets.

    has anyone got a solution for this?

  • Dramew
    Community Member
    9 Posts

    Re: two widgetareas for a page Link to this post

    Maybe it will be useful for someone.
    The only way to have two sidebars I found at the moment is:

    • Create 2 new classes like:

      class SidebarOne extends Page {
         static $db = array();
         static $has_one= array(
            "SideBar" => "WidgetArea",
      class SidebarTwo extends Page {
         static $db = array();
         static $has_one= array(
            "SideBar" => "WidgetArea",

    • Then you can get them with (put this in Page_Controller):

      /*** Get Widgets to show 'em on a page*/
      public function GetSidebarOne(){
      return DataObject::get_one("SidebarOne");
      public function GetSidebarTwo(){
      return DataObject::get_one("SidebarTwo");

    • In templates use smth like:

      <% if GetSidebarOne %>
         <% control GetSidebarOne %>
         <% end_control %>
      <% end_if %>

    Not sure if it is the best way, but nevertheless.

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.