21489 Posts in 5783 Topics by 2622 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 852 Views |
-
two widgetareas for a page

15 February 2009 at 6:24pm
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?
-
Re: two widgetareas for a page

18 February 2010 at 8:03pm
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 %>
$SideBar
<% end_control %>
<% end_if %>
Not sure if it is the best way, but nevertheless.
- Create 2 new classes like:
| 852 Views | ||
|
Page:
1
|
Go to Top |


