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.

Widgets /

Discuss SilverStripe Widgets.

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

General Widget Question


Go to End
Reply


13 Posts   6538 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:

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

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, 58 Posts

12 August 2013 at 8:42am

Removing the comma worked for me, thank you.

Go to Top