17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1438 Views |
-
Include a widget on all pages

24 July 2008 at 8:59am
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 -
Re: Include a widget on all pages

24 July 2008 at 4:27pm
Hmm I hope my english isn't so bad that nobody understands what I want to do. Anyway, I had a idea how to add a widget on all pages of a specific pagetype or all. Is it possible to create a page with a button for each widget (in the cms). If i click on a button a function will be called which adds for all pages the necessary inserts into the database.
Hmm
Regards Thomas
| 1438 Views | ||
|
Page:
1
|
Go to Top |

