5095 Posts in 1518 Topics by 1114 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 723 Views |
-
Multiple Sidebar and Footer

27 September 2010 at 1:12am
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
-
Re: Multiple Sidebar and Footer

27 September 2010 at 2:38am Last edited: 27 September 2010 2:39am
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:dataobjectmanagerBTW: You don't need double posting here ;)
http://silverstripe.org/template-questions/show/292757#post292757Hope this helps.
-
Re: Multiple Sidebar and Footer

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.
| 723 Views | ||
|
Page:
1
|
Go to Top |


