Jump to:

794 Posts in 409 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » Can you have more than one widget in a page?

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 1385 Views
  • Suzanne
    Avatar
    Community Member
    37 Posts

    Can you have more than one widget in a page? Link to this post

    Hoi,

    I'm a SilverStripe newbie and I'm trying to get a youtube widget and a twitterfeed widget on one and the same page. But when I activate only the youtube widget it works but when i activate the twitterfeed widget as well the both stop working and the other way around. What can I do to get them both work? Is it even possible to get more then one widget on the same page?

    Twitter widget:
    TwitterWidgetPack-0.11.tar.gz

    Youtube widget:
    widgets_featuredvideo-0.1.tar.gz

    PHP file:

    class Mink extends Page {

       public static $db = array(
          
       );

       public static $has_one = array(
          "YouTube" => "WidgetArea",
          "Twitter" => "WidgetArea",
       );
       
       public function getCMSFields() {
          $fields = parent::getCMSFields();
          
          $fields->addFieldToTab("Root.YouTube", new WidgetAreaEditor("YouTube"));
          $fields->addFieldToTab("Root.Twitter", new WidgetAreaEditor("Twitter"));
          
          return $fields;
       }   

    }

    Pieces of the SS file:

    <div class="box-small">
       <div class="box-content">
          <div class="title-small-red">
             <div class="text">
                <h2>@minkemacollege</h2>
                101 volgers
             </div>
          </div>
          <div class="twitter">
             <div class="image"></div>
                <div class="feed">
                   $Twitter
                </div>
             </div>
          </div>
       </div>

    <div class="box-large">
       <div class="box-content">
          <h1>Beleef het Minkema College</h1>
          <object width="350" height="197">
             <div class="box-video">
             $YouTube
          </object>
       </div>

    I have also the widget module.

    Thank you,

    Suzanne

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Can you have more than one widget in a page? Link to this post

    Could you describe the error you get on the page? Or is the error in the backend? Usually you have 1 WidgetArea on a page and add in multiple individual widgets in that 1 area. Not sure if multiple WidgetAreas has been tested.

  • Suzanne
    Avatar
    Community Member
    37 Posts

    Re: Can you have more than one widget in a page? Link to this post

    Hoi Willr,

    It's not rely an error, i've attached a print screen so you can see.
    The youtube widget say's that I should update my flash.
    And the twitter widget just say's Widget title.

    Suzanne

    Attached Files
  • haantje72
    Avatar
    Community Member
    69 Posts

    Re: Can you have more than one widget in a page? Link to this post

    i have pages with 3 widgetareas on ss 2.4 without any problems... made mywidgetarea 1 2 and 3 on on top and one on left and right side. As long theres no javascripterror between the widgets it no problem to show and use.

    It could be that both widgets above have a javascriptproblem. Look in the source of the published page if 2 identical of kind of the same javascripts are loaded. So jquery.5.js and jquery.7.js for instance.

  • SSK
    Avatar
    Community Member
    4 Posts

    Re: Can you have more than one widget in a page? Link to this post

    I currently have 4 widget areas on a homepage without any real problems. I just added some coding to manage them properly from the backend, which I did by adding sub-tabs to the Widgets tab (see picture). Otherwise all the widget areas get heaped up on one Widgets tab, and it's almost impossible to see which widget goes where...
    This is the code for SS 3.05:

    <?php
    class HomePage extends Page {

    static $has_one = array(
    "HomeWidgetArea1" => "WidgetArea",
    "HomeWidgetArea2" => "WidgetArea",
    "HomeWidgetArea3" => "WidgetArea",
    "HomeWidgetArea4" => "WidgetArea"
    );

    public function updateCMSFields(FieldList $fields) {
    $fields->addFieldToTab('Root.Widgets', new TabSet('Tab1'),'Area1');
    $fields->addFieldToTab('Root.Widgets', new TabSet('Tab2'),'Area2');
    $fields->addFieldToTab('Root.Widgets', new TabSet('Tab3'),'Area3');
    $fields->addFieldToTab('Root.Widgets', new TabSet('Tab4'),'Area4');
    }
    public function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab("Root.Widgets.Area1", new WidgetAreaEditor("HomeWidgetArea1"));
    $fields->addFieldToTab("Root.Widgets.Area2", new WidgetAreaEditor("HomeWidgetArea2"));
    $fields->addFieldToTab("Root.Widgets.Area3", new WidgetAreaEditor("HomeWidgetArea3"));
    $fields->addFieldToTab("Root.Widgets.Area4", new WidgetAreaEditor("HomeWidgetArea4"));
    return $fields;
    }

    }

    class HomePage_Controller extends Page_Controller {
    }

    Attached Files
  • Suzanne
    Avatar
    Community Member
    37 Posts

    Re: Can you have more than one widget in a page? Link to this post

    Thank you i'm gonna try it

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