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

How to add widget on frontpage


Go to End
Reply


18 Posts   9293 Views

Avatar
Webdoc

Community Member, 332 Posts

7 December 2009 at 11:03am

added the widget area in page.php like so:

<?php

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;
}

}

How to show the html widget in the frontpage if its draged to widgets in cms

http://www.trikato.ee

Avatar
roterl

Community Member, 44 Posts

9 December 2009 at 2:27am

Edited: 09/12/2009 2:28am

You should add $Sidebar in your template file (.ss)

You will find that you will have to add and configure the widgets for each page.
I wrote a module that make it easy to manage widgets - and allow adding widgets in one place.
http://ssorg.bigbird.silverstripe.com/all-other-modules/show/274910?showPost=275040

Rotem.

Avatar
Webdoc

Community Member, 332 Posts

9 December 2009 at 4:38am

If i use the blackandy where i add $SidebarWidgets

Avatar
roterl

Community Member, 44 Posts

9 December 2009 at 5:20am

Edited: 09/12/2009 5:27am

it most suitable place is in templates/Includes/SideBar.ss
But because blackandy display the sidebar only when there is a second lever menu, you need to make some changes there, to move the <% if Menu(2) %> check from the templates/Layout/Page.ss to the SideBar.ss.

attached the modified files.

Note: for some reason the attached file called Page4.ss instead of Page.ss

Avatar
Webdoc

Community Member, 332 Posts

9 December 2009 at 11:49am

OK but if its installed and i wanna make lets say like widged where i can write what clients think about us how i sue it with widget manager

Avatar
roterl

Community Member, 44 Posts

9 December 2009 at 12:16pm

If that widget should be available to all pages (or anything more that one page), go to the "Widgets Manager" tab, create new widget (or select the default one).
The WidgetArea will come up (same as in the Forum), with extra "name" field. Set the name, Drag the widgets and save.
Then on each page you want to display that widgets, select the "content/widgets" tab and from the "Widgets Manager" pull-down choose the one you created. (and Make sure "Widgets currently used" is empty).
Second level pages will inherit it's parent widgets by default.

If you want the widget to be available only to one page, just use the "content/widgets" tab, drag the widget and save. again, second level pages will inherit that widgets by default.

Avatar
Webdoc

Community Member, 332 Posts

9 December 2009 at 3:41pm

yes but some widget needs the files. ss and .php where i install them i wanna add a widget where the owner can write text via cms in tinymce something like html widget but thisone dont show up in frontpage.

using ss 2.3.3 and htmlwidget and widget manager

Avatar
roterl

Community Member, 44 Posts

10 December 2009 at 5:38am

I dont use the htmlwidget, so I dont know to help you.
BTW: I made update to the WidgetsManager plugin.

Go to Top