All the other page types that include $SideBar are saving widgets fine.
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
- Previous 10 entries
- 1
- Page 22(current)
I remember encountering a similar problem, but I can't for the life of me remember what the solution was, I think it may have been in another forum post. I'll give it a ponder and see whether I can find the solution somewhere.
I had to remove Sidebar and add my own. Make sure all widgets are removed from the pages in the CMS before you do it, otherwise it can cause problems.
Page.php
class Page extends SiteTree {
public static $has_one = array(
'SidebarWidgets' => 'WidgetArea'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Widgets', new WidgetAreaEditor('SidebarWidgets'));
return $fields;
}
}
BlogHolderDecorator.php
class BlogHolderDecorator extends DataObjectDecorator {
public function getCMSFields() {
$fields = parent::getCMSFields();
$this->extend('updateCMSFields', $fields);
return $fields;
}
public function updateCMSFields(FieldSet $fields) {
$fields->removeByName('SideBar');
return $fields;
}
}
_config.php
DataObject::add_extension('BlogHolder', 'BlogHolderDecorator');
YourTemplate.ss
replace $Sidebar with $SidebarWidgets
Thanks everyone. I think the problem lay with my localhost, after numerous errors I dropped the MySQL database and now all is working fine (I used the code from the tutorial with no additions).
The widget list does display twice in the blog CMS admin area (attached), but widgets are not duplicated in the sidebar.
Could you try the code from the post http://www.silverstripe.org/widgets-2/show/16100#post310887 again to see whether it works now? As this should remove the duplication from the CMS.
I tried that code and saved widgets appear in the front end but are now viewable in the CMS (so I am unable to customise them)
- Previous 10 entries
- 1
- Page 22(current)