Jump to:

794 Posts in 409 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » How to add widget on frontpage

Discuss SilverStripe Widgets.

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

Page: 1 2 3
Go to End
Author Topic: 9094 Views
  • Webdoc
    Avatar
    Community Member
    332 Posts

    How to add widget on frontpage Link to this post

    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

  • roterl
    Avatar
    Community Member
    44 Posts

    Re: How to add widget on frontpage Link to this post

    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.

  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: How to add widget on frontpage Link to this post

    If i use the blackandy where i add $SidebarWidgets

  • roterl
    Avatar
    Community Member
    44 Posts

    Re: How to add widget on frontpage Link to this post

    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

    Attached Files
  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: How to add widget on frontpage Link to this post

    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

  • roterl
    Avatar
    Community Member
    44 Posts

    Re: How to add widget on frontpage Link to this post

    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.

  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: How to add widget on frontpage Link to this post

    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

  • roterl
    Avatar
    Community Member
    44 Posts

    Re: How to add widget on frontpage Link to this post

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

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