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 /

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

Two column content

Go to End

5 Posts   3262 Views


Community Member, 117 Posts

22 December 2008 at 5:15am

I'm pretty new to Silverstripe. I've been playing around with the default templates and would like some advise on the best way to handle two column content i.e. multiple pages with main content and then varyiong content in a smaller right column or side bar. I can see how the default Sidebar strcuture works well for showing a menu system, but what about when you want to include additional content further down that might be unique to each page. Anyone offer any advise?

Note: My current thinking is that where this additional content is fairly static you just define additional Page layouts that include the static content you want, or alternative you actually add a secondary Content area to the database, so that via Admin area you can both add main content and content for the sidebar area?

Any recommendations appreciated



Community Member, 400 Posts

22 December 2008 at 3:09pm

I would suggest you to add a dataobject and make a many-many relationship with the pages, then you can create one data object and view its content all around the website.


Community Member, 244 Posts

22 December 2008 at 3:20pm

I think that creating a relationship would is way more complex than is needed - the simplest thing to do would be to just create an additional field the $db static on your Page class, then add an extra field in your getCMSFields() method:

class Page extends SiteTree {
	public static $db = array (
		'SidebarTitle'   => 'Varchar(255)',
		'SidebarContent' => 'HTMLText'
	public function getCMSFields() {
		$fields = parent::getCMSFields();
		$fields->addFieldToTab('Root.Content.Sidebar', new TextField('SidebarTitle', 'Sidebar Item Title'));
		$fields->addFieldToTab('Root.Content.Sidebar', new HtmlEditorField('SidebarContent', null));
		return $fields;

Then in your template (wherever your sidebar content is) you can just add something like:

<!-- Existing Sidebar Stuff -->
<% if SidebarContent %>
	<div id="SidebarContent" class="sidebarItem">
		<h3 class="sidebarTitle">$SidebarTitle</h3>
<% end_if %>


Community Member, 400 Posts

28 December 2008 at 5:33am

yes I agree but though ajshort's method is easy, you will have to duplicate content, my point is not to duplicate content.


Community Member, 6 Posts

18 July 2009 at 1:48am

Sorry for brnging up an old post, but i prefer to read and comment on existing thread rather than start new ones...

What is a dataobject and how do i create one?

If im undertanding Nivanka correctly, i can create a data object and assign it ti whatever pages i want?
So if i make a change to a dataobject that change is applied to all the pages that use this dataobject - much like a global php include?