Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Multiple Widget Areas

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 2807 Views
  • marks
    Avatar
    3 Posts

    Multiple Widget Areas Link to this post

    Dear All,

    We are using a three column layout and would like to set-up two widget areas - one for the left column, and one for the right.

    Everything works well with one widget area but as soon as I add a second widget area to the page it stops working in the admin area. It looks like the problem is that the Javascript uses an ID to locate the widget area and if you have two areas it breaks.

    Does anyone know if its possible to have two widget areas on the same page?

    Thanks in advance.

    Mark

  • MIke
    Avatar
    Community Member
    7 Posts

    Re: Multiple Widget Areas Link to this post

    Same Issue, could we make two class Widget aera 1 and 2 ?

  • simon_w
    Avatar
    Forum Moderator
    467 Posts

    Re: Multiple Widget Areas Link to this post

    Do they have different names?

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Multiple Widget Areas Link to this post

    Im pretty sure 2 widget areas will work. Following the example on the widgets page in the docs you would have 2 widgetareas defined (eg LeftSideWidgets, RightSideWidgets) instead of 1.

  • MIke
    Avatar
    Community Member
    7 Posts

    Re: Multiple Widget Areas Link to this post

    Hi,

    I tryed yesterday many way to use two widget aera on a left sidebar
    and a right sidebar. I tried 3 approach . And at each time the admin section was not working properly.
    I was not able to drag Widget from the WidgetAeraEditor_availableWidget form the right side bar.

    /*---------------------------------------------*/
    /*----------- 1st approach -------------*/

    Just to create in a page.php a second widget

    class Page extends SiteTree {
       static $db = array(
       
       );
       static $has_one = array(
       "leftSidebar" => "WidgetArea",
       "RightSidebar" => "WidgetArea"
    );

    function getCMSFields() {
       $fields = parent::getCMSFields();
       $fields->addFieldToTab("Root.Content.SideBar", new WidgetAreaEditor("leftSidebar"));
       $fields->addFieldToTab("Root.Content.SideBar", new WidgetAreaEditor("RightSidebar"));
       return $fields;
    }

    }

    /*-------- Result -----------*/
    -> i ran db/build?flush=1
    -> /admin and I am able to manage only the section of left
    and it appear (after saving and refresh) the same widget value in both WidgetAreaEditor_usedWidgets and delete work only in the left (first) one

    /*---------------------------------------------*/
    /*----------- 2nd approach -------------*/

    Just to create in a page.php a second widget but manage in a second tab

    class Page extends SiteTree {
       static $db = array(
       
       );
       static $has_one = array(
       "leftSidebar" => "WidgetArea",
       "RightSidebar" => "WidgetArea"
    );

    function getCMSFields() {
       $fields = parent::getCMSFields();
       $fields->addFieldToTab("Root.Content.LeftSideBar", new WidgetAreaEditor("leftSidebar"));
       $fields->addFieldToTab("Root.Content.RightSideBar", new WidgetAreaEditor("RightSidebar"));
       return $fields;
    }

    }

    /*-------- Result -----------*/
    -> i ran db/build?flush=1
    -> admin and I am able to manage only the section of LeftSideBar and nothing move in WidgetAreaEditor_availableWidgets in the RightSideBar tab

    /*---------------------------------------------*/
    /*----------- 3rd approach -------------*/

    stupid approach crate a new class RightWidgetArea in C:\....\lighttpd\htdocs\sapphire\widgets

    <?php

    class RightWidgetArea extends DataObject {
       static $db = array();
       
       static $has_many = array(
          "Widgets" => "Widget"
       );
       
       function forTemplate() {
          return $this->renderWith("WidgetArea");
       }
    }

    ?>

    and then

    class Page extends SiteTree {
       static $db = array(
       
       );
       static $has_one = array(
       "leftSidebar" => "WidgetArea",
       "RightSidebar" => "RightWidgetArea "
    );

    function getCMSFields() {
       $fields = parent::getCMSFields();
       $fields->addFieldToTab("Root.Content.LeftSideBar", new WidgetAreaEditor("leftSidebar"));
       $fields->addFieldToTab("Root.Content.RightSideBar", new WidgetAreaEditor("RightSidebar"));
       return $fields;
    }

    }

    /*-------- Result -----------*/
    (same has the 2nd approach)

    -> i ran db/build?flush=1
    -> admin and I am able to manage only the section of LeftSideBar and nothing move in WidgetAreaEditor_availableWidgets in the RightSideBar tab

    /*--- Please help me ---*/

    I will finish by hardcode and rendering manualy the widget of the right side bar..
    But i am sure some one already succes to manage 2 section of widget on one page, doesn't you ?
    So any idea is more than welcome

    have a good one
    MIke

    10 types of people , developers and .. others

  • MIke
    Avatar
    Community Member
    7 Posts

    Re: Multiple Widget Areas Link to this post

    Ok, i know my previous msg was a little too long but to resume , no you can not administer 2 widget aera for the moment.. or for me something is missing..
    Do you have any idea how to do this ?

  • oc
    Avatar
    Community Member
    3 Posts
    2807 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.