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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

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

Multiple Sidebar and Footer

Go to End

3 Posts   1226 Views


Community Member, 18 Posts

27 September 2010 at 1:12am


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




Community Member, 271 Posts

27 September 2010 at 2:38am

Edited: 27/09/2010 2:39am

Have you tried this?

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 = ''){
    return DataObject::get('ContentBlock', "Position='".$position."'");

In your template:

<% if ContentBlocks(Left) %>
  <div id="ContentLeft">
  <% control ContentBlocks(Left) %>
    <div class="contentblock">
  <% end_control%>
<% 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:

BTW: You don't need double posting here ;)

Hope this helps.


Community Member, 18 Posts

27 September 2010 at 4:18pm

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.