Hi,
I have got a question, about widgets. Is it possible to add a specific widget to all pages by default. I have have done a work around to do that, but this work around is code based so I have no influence on the behavior from the cms.
I have included the following gode to the page model.
static $has_one = array(
"Sidebar" => "WidgetArea",
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("Sidebar"));
return $fields;
}
and in the page controller I do the following
public function Sidebar() {
$w = new SidebarWidget();
return $w->renderWith('SidebarWidget');
}
Now the widget is visible on all pages which inherits from page. The problem is that you have no influance on turning it on or off in the cms. Has anyone a idea to add a widget to all pages without it to all pages manually?
Best regards
Thomas