Jump to:

794 Posts in 409 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » more than a widget area

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 1401 Views
  • bebabeba
    Avatar
    Community Member
    192 Posts

    more than a widget area Link to this post

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

  • bebabeba
    Avatar
    Community Member
    192 Posts

    Re: more than a widget area Link to this post

    any idea?

  • Yasen
    Avatar
    Community Member
    4 Posts

    Re: more than a widget area Link to this post

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

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: more than a widget area Link to this post

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

  • Yasen
    Avatar
    Community Member
    4 Posts

    Re: more than a widget area Link to this post

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

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: more than a widget area Link to this post

    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

  • Yasen
    Avatar
    Community Member
    4 Posts

    Re: more than a widget area Link to this post

    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.

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