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

General Widget Question


Go to End


13 Posts   10039 Views

Avatar
ulysses

Community Member, 57 Posts

24 November 2009 at 2:23pm

Edited: 24/11/2009 2:24pm

Hi Will,

I have tried following the instructions from the doku page:

http://doc.silverstripe.org/doku.php?id=widgets#adding_widgets_to_other_pages

This ends up duplicating the Available Widgets section on the Widgets tab in the CMS.

The original Page.php had the following:

class Page extends SiteTree {

public static $db = array(
);

public static $has_one = array(
);

}

Applying the instructions, the above now looks like this:

class Page extends SiteTree {

public static $db = array(
);

public static $has_one = array(
"Sidebar" => "WidgetArea",
);

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

}

What am I doing wrong?

Can you please advise.

Thanks

Mauricio

Avatar
Funfair77

Community Member, 49 Posts

17 June 2010 at 3:07am

Hello Ulysses/Mauricio,

What was your solution for this widget problem?

Thank you!

Marnix

Avatar
ulysses

Community Member, 57 Posts

18 June 2010 at 10:50pm

Never got a response from anyone on this. I gave up!!

Mauricio

Avatar
MartinPhone

Community Member, 57 Posts

7 November 2010 at 10:34am

Edited: 07/11/2010 10:36am

I think you may simply have a comma here:

   public static $has_one = array( 
   "Sidebar" => "WidgetArea", 
);

when you shouldn't. It's a bit funny it's in the documentation like that but looking at my code, the last item in the array has no comma at the end.

Avatar
Christy

Community Member, 68 Posts

12 August 2013 at 8:42am

Removing the comma worked for me, thank you.

Go to Top