Jump to:

794 Posts in 408 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » General Widget Question

Discuss SilverStripe Widgets.

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

Page: 1 2
Go to End
Author Topic: 6236 Views
  • ulysses
    Avatar
    Community Member
    57 Posts

    Re: General Widget Question Link to this post

    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

  • Funfair77
    Avatar
    Community Member
    49 Posts

    Re: General Widget Question Link to this post

    Hello Ulysses/Mauricio,

    What was your solution for this widget problem?

    Thank you!

    Marnix

  • ulysses
    Avatar
    Community Member
    57 Posts

    Re: General Widget Question Link to this post

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

    Mauricio

  • MartinPhone
    Avatar
    Community Member
    57 Posts

    Re: General Widget Question Link to this post

    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.

  • Christy
    Avatar
    Community Member
    57 Posts

    Re: General Widget Question Link to this post

    Removing the comma worked for me, thank you.

    6236 Views
Page: 1 2
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.