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