Jump to:

5554 Posts in 1742 Topics by 1227 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Moving Blog widgets to my site template

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

Page: 1
Go to End
Author Topic: 1332 Views
  • _dp
    Avatar
    Community Member
    3 Posts

    Moving Blog widgets to my site template Link to this post

    So, i set up the blog module to manage my news entries on the frontpage.
    i created my own template with a fixed sidebar defined in the Page.ss template file.

    i now want to move all the widgets from the blog into this sidebar section and only displaying them on the blog page or entries of the blog. (i dont want the archive box be displayed on the "about-us" page for example)

    so i tried to follow this small tutorial: http://doc.silverstripe.org/doku.php?id=widgets#adding_widgets_to_other_pages
    and my page.php file looked in this section like this:

    <?php

    class Page extends SiteTree {
       
       public static $db = array(
       );
       
       public static $has_one = array(
          "Sidebar" => "WidgetArea"
       );

    function getCMSFields()
          {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab("blog.Widget.ArchiveWidget", new WidgetAreaEditor("Sidebar"));
          return $fields;
        }

    }

    ...


    And unfortunately this doesnt work. My site throws an Website error and i have not the slightest idea how to solve this.

    Where do i learn which path to use for a widget i want to include? The tutorial says "Root.Content.Widgets" but where are these packages?

    Do i have to use the term "Sidebar"? And why does the authore make use of the term "Sidebar" and calling the object with $SideBar in the template? Isn't Silverstripe case-sensitive?

    Can i use any term for this? for example could i just write "Area-to-put-all-the-blog-widgets-in" instead of "Sidebar" ? Or is it connected in some ways to other parts of the template?

  • arthurdent
    Avatar
    Community Member
    165 Posts

    Re: Moving Blog widgets to my site template Link to this post

    Hi. I'm in middle of the development of a new SS site and have struck exactly the same problem -- my main navigation is in the Sidebar area which works fine across all page until I come the Blog module. Then I get the blog widgets (admin, tag cloud, etc) sitting on top of my navbar.

    I've just added "$SideBar" beneath my Navigation pane and the blog widgets now show up in the correct place on the page - and just on the relevant Blog page (as opposed to ALL pages in the site -- which is really cool! Apart from one thing -- the Blog widgets also appear at the top of the navbar. In other words, I get them TWICE! (which just looks like overkill)

    Currently looking for an .SS or PHP file that's causing this. Can anybody give me any pointers?

    thanks!

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