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.

General Questions /

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

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

Add a Widget not in blog module


Go to End


4 Posts   2584 Views

Avatar
Conejo

Community Member, 8 Posts

23 August 2010 at 10:25pm

Edited: 24/08/2010 9:36pm

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???

Avatar
Willr

Forum Moderator, 5523 Posts

24 August 2010 at 9:30pm

Edited: 24/08/2010 9:36pm

   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"
);

Avatar
Conejo

Community Member, 8 Posts

24 August 2010 at 10:44pm

It works!

Thanks a lot!

Conejo!!

Avatar
toarx

Community Member, 34 Posts

13 October 2011 at 8:29pm

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