Jump to:

794 Posts in 409 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » New Blog 4 module issues - Widgets on all pages

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 1413 Views
  • Tris
    Avatar
    Community Member
    3 Posts

    New Blog 4 module issues - Widgets on all pages Link to this post

    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.

  • Anatol
    Avatar
    126 Posts

    Re: New Blog 4 module issues - Widgets on all pages Link to this post

    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

  • Tris
    Avatar
    Community Member
    3 Posts

    Re: New Blog 4 module issues - Widgets on all pages Link to this post

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

    1413 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.