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

Can you have more than one widget in a page?


Go to End


6 Posts   3199 Views

Avatar
Suzanne

Community Member, 37 Posts

27 September 2012 at 9:09pm

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

Avatar
Willr

Forum Moderator, 5523 Posts

30 September 2012 at 6:26pm

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.

Avatar
Suzanne

Community Member, 37 Posts

2 October 2012 at 7:49pm

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
Avatar
haantje72

Community Member, 69 Posts

6 October 2012 at 6:21am

Edited: 06/10/2012 6:27am

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.

Avatar
SSK

Community Member, 4 Posts

10 May 2013 at 1:03am

Edited: 10/05/2013 1:05am

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
Avatar
Suzanne

Community Member, 37 Posts

10 May 2013 at 1:51am

Thank you i'm gonna try it