Jump to:

22979 Posts in 11815 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Add a Widget not in blog module

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1560 Views
  • Conejo
    Avatar
    Community Member
    8 Posts

    Add a Widget not in blog module Link to this post

    Hallo!

    I am would like to add a widget area in an other page as the blog.
    Conditions:
    Silverstripe 2.4
    theme: higherground
    No blog module used

    MySite/Code/Page.php is:
    class Page extends SiteTree {

       public static $db = array(
       );

       public static $has_one = array(
       );
       
       // Integrate widgets area in backend...
       static $has_one = array(
       "SideBar" => "WidgetArea");
          
          function getCMSFields()
          {
             $fields = parent::getCMSFields();
             $fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("SideBar"));
             return $fields;
             
       }
       // End Integrate widgets area in backend...

    }

    after a http://localhost:8888/dev/build and a http://localhost:8888/?flush=1
    I get a blank page

    Can any one help me???

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Add a Widget not in blog module Link to this post

    public static $has_one = array(
    );

    // Integrate widgets area in backend...
    static $has_one = array(
    "SideBar" => "WidgetArea");

    You only declare $has_one once per class. So that needs to be

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

  • Conejo
    Avatar
    Community Member
    8 Posts

    Re: Add a Widget not in blog module Link to this post

    It works!

    Thanks a lot!

    Conejo!!

  • toarx
    Avatar
    Community Member
    34 Posts

    Re: Add a Widget not in blog module Link to this post

    Hello Conejo, I want to use also widgets without blog-modul, but I cannot follow your example, you talk with Willr about it.
    What is necessary and how to use it? It would be very nice, if you'll explain your method step by step.
    Thanks Uwe

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