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.

Customising the CMS

Multiple Sidebar and Footer


Reply

3 Posts   862 Views

Avatar
hunman

27 September 2010 at 1:12am Community Member, 18 Posts

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

Avatar
Martijn

27 September 2010 at 2:38am (Last edited: 27 September 2010 2:39am), Community Member, 271 Posts

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.

Avatar
hunman

27 September 2010 at 4:18pm Community Member, 18 Posts

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.