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.

Archive /

Our old forums are still available as a read-only archive.

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

Multiple Widget Areas


Reply


7 Posts   2921 Views

Avatar
marks

3 Posts

17 October 2007 at 3:06am

Edited: 17/10/2007 3:07am

Dear All,

We are using a three column layout and would like to set-up two widget areas - one for the left column, and one for the right.

Everything works well with one widget area but as soon as I add a second widget area to the page it stops working in the admin area. It looks like the problem is that the Javascript uses an ID to locate the widget area and if you have two areas it breaks.

Does anyone know if its possible to have two widget areas on the same page?

Thanks in advance.

Mark

Avatar
MIke

Community Member, 7 Posts

18 April 2008 at 1:30pm

Same Issue, could we make two class Widget aera 1 and 2 ?

Avatar
simon_w

Forum Moderator, 474 Posts

18 April 2008 at 4:10pm

Do they have different names?

Avatar
Willr

Forum Moderator, 5513 Posts

18 April 2008 at 5:38pm

Im pretty sure 2 widget areas will work. Following the example on the widgets page in the docs you would have 2 widgetareas defined (eg LeftSideWidgets, RightSideWidgets) instead of 1.

Avatar
MIke

Community Member, 7 Posts

19 April 2008 at 12:46am

Hi,

I tryed yesterday many way to use two widget aera on a left sidebar
and a right sidebar. I tried 3 approach . And at each time the admin section was not working properly.
I was not able to drag Widget from the WidgetAeraEditor_availableWidget form the right side bar.

/*---------------------------------------------*/
/*----------- 1st approach -------------*/

Just to create in a page.php a second widget

class Page extends SiteTree {
   static $db = array(
   
   );
   static $has_one = array(
   "leftSidebar" => "WidgetArea",
   "RightSidebar" => "WidgetArea"
);

function getCMSFields() {
   $fields = parent::getCMSFields();
   $fields->addFieldToTab("Root.Content.SideBar", new WidgetAreaEditor("leftSidebar"));
   $fields->addFieldToTab("Root.Content.SideBar", new WidgetAreaEditor("RightSidebar"));
   return $fields;
}

}

/*-------- Result -----------*/
-> i ran db/build?flush=1
-> /admin and I am able to manage only the section of left
and it appear (after saving and refresh) the same widget value in both WidgetAreaEditor_usedWidgets and delete work only in the left (first) one

/*---------------------------------------------*/
/*----------- 2nd approach -------------*/

Just to create in a page.php a second widget but manage in a second tab

class Page extends SiteTree {
   static $db = array(
   
   );
   static $has_one = array(
   "leftSidebar" => "WidgetArea",
   "RightSidebar" => "WidgetArea"
);

function getCMSFields() {
   $fields = parent::getCMSFields();
   $fields->addFieldToTab("Root.Content.LeftSideBar", new WidgetAreaEditor("leftSidebar"));
   $fields->addFieldToTab("Root.Content.RightSideBar", new WidgetAreaEditor("RightSidebar"));
   return $fields;
}

}

/*-------- Result -----------*/
-> i ran db/build?flush=1
-> admin and I am able to manage only the section of LeftSideBar and nothing move in WidgetAreaEditor_availableWidgets in the RightSideBar tab

/*---------------------------------------------*/
/*----------- 3rd approach -------------*/

stupid approach crate a new class RightWidgetArea in C:\....\lighttpd\htdocs\sapphire\widgets

<?php

class RightWidgetArea extends DataObject {
   static $db = array();
   
   static $has_many = array(
      "Widgets" => "Widget"
   );
   
   function forTemplate() {
      return $this->renderWith("WidgetArea");
   }
}

?>

and then

class Page extends SiteTree {
   static $db = array(
   
   );
   static $has_one = array(
   "leftSidebar" => "WidgetArea",
   "RightSidebar" => "RightWidgetArea "
);

function getCMSFields() {
   $fields = parent::getCMSFields();
   $fields->addFieldToTab("Root.Content.LeftSideBar", new WidgetAreaEditor("leftSidebar"));
   $fields->addFieldToTab("Root.Content.RightSideBar", new WidgetAreaEditor("RightSidebar"));
   return $fields;
}

}

/*-------- Result -----------*/
(same has the 2nd approach)

-> i ran db/build?flush=1
-> admin and I am able to manage only the section of LeftSideBar and nothing move in WidgetAreaEditor_availableWidgets in the RightSideBar tab

/*--- Please help me ---*/

I will finish by hardcode and rendering manualy the widget of the right side bar.. :-(
But i am sure some one already succes to manage 2 section of widget on one page, doesn't you ?
So any idea is more than welcome :-)

have a good one
MIke

10 types of people , developers and .. others

Avatar
MIke

Community Member, 7 Posts

19 April 2008 at 7:52am

Edited: 19/04/2008 7:52am

Ok, i know my previous msg was a little too long but to resume , no you can not administer 2 widget aera for the moment.. or for me something is missing..
Do you have any idea how to do this ?

Avatar
oc

Community Member, 3 Posts

6 May 2008 at 6:02pm

See http://open.silverstripe.com/ticket/2131