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

more than a widget area


Go to End


7 Posts   2418 Views

Avatar
bebabeba

Community Member, 193 Posts

3 August 2010 at 12:58am

Edited: 03/08/2010 2:22am

hi!
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 http://open.silverstripe.org/ticket/2131 in a post. I must copy in my Silverstripe code this correct file? I try but don't work..in my Page.php i write:
public static $has_one = array(
'Widget1'=>'WidgetArea',
'Widget2'=>'WidgetArea');

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.

thanks!!

Avatar
bebabeba

Community Member, 193 Posts

3 August 2010 at 6:31pm

any idea?

Avatar
Yasen

Community Member, 4 Posts

2 October 2010 at 4:18am

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

Avatar
swaiba

Forum Moderator, 1899 Posts

2 October 2010 at 4:42am

Edited: 02/10/2010 4:44am

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...

Avatar
Yasen

Community Member, 4 Posts

2 October 2010 at 4:46am

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 http://ssorg.bigbird.silverstripe.com/widgets-2/show/261491

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

Avatar
swaiba

Forum Moderator, 1899 Posts

2 October 2010 at 4:52am

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

Avatar
Yasen

Community Member, 4 Posts

5 October 2010 at 5:10am

Edited: 05/10/2010 9:43pm

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 BannerWidget.ss 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.