Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

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.

Widgets /

Discuss SilverStripe Widgets.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

New Blog 4 module issues - Widgets on all pages


Go to End


3 Posts   2544 Views

Avatar
Tris

Community Member, 3 Posts

6 August 2010 at 9:53am

Hello,

I'm trying to add widgets to all of my pages. I also have the blog installed.

The double widget issue was occurring and I tried to follow the example here:http://doc.silverstripe.org/widgets?s=widgets.
However the code is different in the new blog release for (BlogHolder class). The $has_one is in the sitetree.php page instead of blogholder.

I'm not sure how to stop the doubling widgets (in the admin) without breaking the blog.

Avatar
Anatol

126 Posts

10 August 2010 at 4:14pm

Edited: 10/08/2010 4:14pm

Hi Tris,

I just had the same problem with Silverstripe 2.4.1.

Same as you I followed the steps at http://doc.silverstripe.org/widgets#adding_widgets_to_other_pages to enable Widgets on all pages which works fine, but I also ended up with a doubled-up widgets area editor on blog holder pages in the CMS.

Here is a workaround. Maybe it's not the ideal way but it seems to work. In /mysite/page.php in the Page class where you defined the WidgetAreaEditor for the interface (as described in the link above) simply make sure that Silverstripe does not do this for the BlogHolder page type because this causes the double WidgetAreaEditor. Here is the if statement I added (in green):

if($this->ClassName != 'BlogHolder') {
	$fields->addFieldToTab('Root.Content.Widgets', new WidgetAreaEditor('Sidebar'));
}

In versions prior to 2.4 I could simply remove the WidgetAreaEditor from BlogHolder.php but that doesn't seem to work properly any more since the WidgetAreaEditor was moved to BlogTree.php .

I hope that helps.

Cheers!
Anatol

Avatar
Tris

Community Member, 3 Posts

11 August 2010 at 9:20am

Ah, what a simple solution.
It does help! Thank you Anatol!