Jump to:

3435 Posts in 1026 Topics by 866 members

Template Questions

SilverStripe Forums » Template Questions » Two sidebars in a theme? or modifying a theme

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

Page: 1 2
Go to End
Author Topic: 3545 Views
  • robcub
    Avatar
    Community Member
    14 Posts

    Two sidebars in a theme? or modifying a theme Link to this post

    Hi, I'm just starting out with SiverStripe having previously only used WordPress.

    I am trying to modify Blackcandy to get it to look like this: http://robcubbon.com/dev/my-local-mates/

    My first question is how to insert the sidebars, as I have a left sidebar and a right sidebar which should remain the same throughout the whole of the site. I'm a bit confused as to why Blackcandy has style for a sidebar but it doesn't always show up.

    Or, is there another existing theme with two sidebars already that would be a better start to modify?

    I have found this article http://www.ssbits.com/create-a-static-sidebar but I'm a little reluctant to go ahead with this.

    If anyone could point me in the right direction I would be grateful. I should be OK with the HTML and CSS of the page.

    Looking forward generally to using SilverStripe in the future!

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: Two sidebars in a theme? or modifying a theme Link to this post

    I find the easiest way to do this is to put sidebar templates in your theme's /Include directory. Just put them in their own .ss file like this:

    /Includes/LeftSideBar.ss

    <div id="LeftSideBar">
    <h2>This is my Left Side Bar</h2>
    </div>

    /Includes/RightSideBar.ss

    <div id="RightSideBar">
    <h2>This is my Left Side Bar</h2>
    </div>

    Then in your Page.ss

    <div id="page">

    <% include LeftSideBar %>

    $Layout

    <% include RightSideBar %>

    </div>

    All the work here is basically HTML. I usually get the page displaying as I want it, with all my code on Page.ss, then I split it out into sections as I find common elements across page types.

    If however you need to populate those sidebars with data from SS, like menus of the SiteTree, you will find plenty of posts in these forums on that.

    Cheers
    Aaron

  • robcub
    Avatar
    Community Member
    14 Posts

    Re: Two sidebars in a theme? or modifying a theme Link to this post

    Thank you so much, Double-A-Ron, for replying with straightforward and logical instructions! I will follow them now.

    One question though, is the Page.ss you are referring to the blackcandy/templates/Page.ss rather than the blackcandy/templates/Layout/Page.ss?

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: Two sidebars in a theme? or modifying a theme Link to this post

    NOTE: I changed the code slightly above - it is now correct.

    It really depends on how you plan to develop the site.

    /templates/Page.ss is the main page template. So any new page type that extends Page will use this file as a basis, and thus wrap all the HTML there-in around whatever HTML you have in /templates/Layout/Page.ss (or MyPage.ss if you create a new Page Type of that name).

    Think of it like /templates/Page.ss is your master template for the site (this can be overridden however), and /templates/Layout/Page.ss is more for laying out the content of the page.

    If it were me, and these side bars were site-wide, I would put those include commands in /templates/Page.ss. That way, if you create a new PageType called say, "MyPage", later and only have content layout changes, keeping the overall design the same, you can put this in /templates/Layout/MyPage.ss. Silverstripe will still use /templates/Page.ss to template the core HTML of your site.

    You should probably play around with the tutorials, this one in particular.

    It's a little confusing at first, but just play around a bit and you'll see that this template system is the way it is for a very cool reason.

    Cheers
    Aaron

  • robcub
    Avatar
    Community Member
    14 Posts

    Re: Two sidebars in a theme? or modifying a theme Link to this post

    Thank you, Aaron, I think I've got it. And I note the changes to the code above. Thank you so much.

    Cheers,

    Rob

  • Nivanka
    Avatar
    Community Member
    395 Posts

    Re: Two sidebars in a theme? or modifying a theme Link to this post

    I tried this once and gave up because you cant use two widget choosers in the same page. is there a solution for this?

  • robcub
    Avatar
    Community Member
    14 Posts

    Re: Two sidebars in a theme? or modifying a theme Link to this post

    Aaron's solution worked a treat for two sidebars, not sure if both can be widgetized, though, Nivanka.

  • Govpatel
    Avatar
    Community Member
    13 Posts

    Re: Two sidebars in a theme? or modifying a theme Link to this post

    I have done as per Aron post and put css code for the sidebars and I find that they are both in on the page but they left hand sidebar at top right hand side and right hand sidebar at bottom left hand side on the main content what am I doing wrong here help will much appreciated.

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