745 Posts in 310 Topics by 288 members
| Go to End | ||
| Author | Topic: | 1748 Views |
-
Re: Blog Widget duplicated in Sidebar - Please Help!

21 June 2012 at 8:04pm
All the other page types that include $SideBar are saving widgets fine.
-
Re: Blog Widget duplicated in Sidebar - Please Help!

21 June 2012 at 9:55pm
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.
-
Re: Blog Widget duplicated in Sidebar - Please Help!

22 June 2012 at 9:35am
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 -
Re: Blog Widget duplicated in Sidebar - Please Help!

24 June 2012 at 12:56am
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.
-
Re: Blog Widget duplicated in Sidebar - Please Help!

24 June 2012 at 2:26am
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.
-
Re: Blog Widget duplicated in Sidebar - Please Help!

24 June 2012 at 6:59pm
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)
| 1748 Views | ||
| Go to Top |



