Jump to:

5514 Posts in 1733 Topics by 1219 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Multiple Sidebar and Footer

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

Page: 1
Go to End
Author Topic: 850 Views
  • hunman
    Avatar
    Community Member
    18 Posts

    Multiple Sidebar and Footer Link to this post

    Hi,

    I need two sidebars, one on left and other on right in my template , also a footer bar in the bottom. I want to populate content in these sidebars and footer from the back-end only but not manually.

    Which is the best way to achieve this functionality ??? Please Help

    Regards,

    Kumar

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: Multiple Sidebar and Footer Link to this post

    Have you tried this?

    http://www.ssbits.com/create-a-static-sidebar/

    This method describes how to use a PageType to manage a single Sidebar thats the same across all pages..

    You can also use widgets to populate sidebars with pieces of custom content.

    An other way is to create a DataObject subclass and manage these with ModelAdmin. You can give these DataObjects a position field to decide where the DataObjects need to be shown.

    Simple example (not tested):

    class ContentBlock extends DataObject{
    static $db = array(
    'Title' = 'Varchar(255)',
    'Content' = 'HTMLText'
    'Position' = "'Left, Right, Top', 'Top'"
    );
    }

    in Page.php you create a method to get the ContentBlocks:

    function ContentBlocks($position = ''){
    if($position){
    return DataObject::get('ContentBlock', "Position='".$position."'");
    }
    }

    In your template:

    <% if ContentBlocks(Left) %>
    <div id="ContentLeft">
    <% control ContentBlocks(Left) %>
    <div class="contentblock">
    <h3>$Title</h3>
    $Content
    </div>
    <% end_control%>
    </div>
    <% end_if %>

    This does not cover the ordering of the contentblocks, but this should get you started.
    You can use DataObjectManager for example, to manage the ContentBlock DataObjects and add $sortable_class to the DataObject.

    Further reading:
    http://doc.silverstripe.org/dataobject
    http://doc.silverstripe.org/modeladmin
    http://doc.silverstripe.org/modules:dataobjectmanager

    BTW: You don't need double posting here ;)
    http://silverstripe.org/template-questions/show/292757#post292757

    Hope this helps.

  • hunman
    Avatar
    Community Member
    18 Posts

    Re: Multiple Sidebar and Footer Link to this post

    Hi Martijn,

    Thank you for your post, I think this will help me to achieve my task.

    Also I think the content order can be achieved by including another field say "order" and fetching the records based on this order.

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