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.


Discuss SilverStripe Widgets.

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

more than a widget area


7 Posts   1408 Views


3 August 2010 at 12:58am (Last edited: 3 August 2010 2:22am), Community Member, 192 Posts

I have two question about widget:

1. I need to use two widget area (two widget tab in my admin cms). Is possible to do this operations? I found this link in a post. I must copy in my Silverstripe code this correct file? I try but don't my Page.php i write:
public static $has_one = array(
   function getCMSFields() {
   $fields = parent::getCMSFields();
   $fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("Widget1"));
   $fields->addFieldToTab("Root.Content.Widgets2", new WidgetAreaEditor("Widget2"));
   return $fields;

2. Is possible choose what type of widget I can use in the first area and what in the second area? For example: I want widget A, B, C in area A and widget D,F in area B. My idea was to create two main folder in root (Widget_A and Widget_B) and insert here the widget that i download from site.



3 August 2010 at 6:31pm Community Member, 192 Posts

any idea?


2 October 2010 at 4:18am Community Member, 4 Posts

I'm wondering the same thing... I could make a new tab with widgets, but how to select which widgets to show there?


2 October 2010 at 4:42am (Last edited: 2 October 2010 4:44am), Forum Moderator, 1796 Posts

Did you not try the suggestion at the start of this thread?

looks good to me and I'm interested in getting this working for future projects...


2 October 2010 at 4:46am Community Member, 4 Posts

I did try it and the result is 2 tabs with all the widgets. I'm trying to group the widgets...

There is a similar topic

I'm trying to extend WidgetAreaEditor now. Hoping to do the job...


2 October 2010 at 4:52am Forum Moderator, 1796 Posts

Ahhh I like that, that will be useful, it might be easier then to instead setup widget area sepearatly from pages (maybe in modelamdin, as a windgetareagroup dataobjectset) and then select multiple windgetareagroups for each page


5 October 2010 at 5:10am (Last edited: 5 October 2010 9:43pm), Community Member, 4 Posts

Been having some success....

Made an additional tab "Banners" in the admin area which shows only two widgets: BannerLongWidget and BannerSquareWidget. And the other tab Widgets contains the other widgets without the banners ones. Two files extend WidgetAreaEditor to filter the showed and used banners in both tabs (in admin area) and to filter them again when saving data in the database. By filtering I mean grouping banners and the other widgets.
There are 2 problems so far I think:
1. When trying to delete a widget, I can only delete a widget from the tab Banners (which is placed before the Widgets one) and can't delete widgets from the other one. I don't understand quite well the JavaScript in SS...
2. The widgets from both tabs are still placed in the WidgetArea holder. Not quite sure how to move them to my custom area...

Edit: The workaround I came up with is putting all widgets in the widget area as it's meant to be and moving some of them by custom JS where ever I need to. It is ugly as hell, but at least this way I could allow my client to put widgets (in my case banners) on areas other then the widget area... The custrom JS is inserted in file or the widget that needs to be moved. Other drawback is that the custom JS may not work for all pages because the DOM differs from page to page... so that would require more custom JS.