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:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

How to fill my sidebar?

Go to End

3 Posts   1336 Views


Community Member, 141 Posts

3 May 2010 at 5:09am

On my website is a sidebar where I want to show some related informations, related pages, internal promotions etc.

At first I thought I'll create a new tab and some text-inputs in the back-end to write all these (it's a pretty cool feature in SS :-). But as I've seen there are about 15-20 "snippets" I want to use and they repeat on other pages I think it isn't the best way to write the same more than once.

Is there a nice and cool way in SS I can fill my sidebar? Can you please give me some insights and share experience? That would be great!


Community Member, 135 Posts

5 May 2010 at 1:14pm

Edited: 05/05/2010 1:15pm

From what I understand, you want one unique sidebar that you can edit in the cms and display on multiple pages?

What I would do is create a new page in the root of the website called 'Sidebar'.
Make this page hidden from the menu and search.
In the content put what you want in the sidebar.
Then in the page templates, where you want the side bar to go you call the following:

<% control Page(sidebar) %>
<% end_control %>


Community Member, 141 Posts

24 May 2010 at 1:55am

Hi ampedup.
Yes, I want a unique sidebar but not only one but for different sections different sidebars (content).

I followed an example (German SS Forum but can not complete it.

What I have:
There is a new SiteTree select field above my 'content' in the back-end where I can select a page. But when I click save my selection gets lost, it seems SS can't save it in the DB, although there is no error.

The Code: (mysite/code/Page.php)

class Page extends SiteTree {
	static $db = array(
	static $has_one = array(
		'Hintergrundbild' => 'Image',
		'Sidebar' => 'Page'
   // Verbindung Hintergrundbild zur Bild-Datenbank
   function getCMSFields() {
      $fields = parent::getCMSFields();
      $fields->addFieldToTab("Root.Content.Hintergrundbild", new ImageField('Hintergrundbild'));
      $fields->addFieldToTab('Root.Content.Main', new TreeDropdownField("Sidebar", "Sidebar anzeigen", "SiteTree"), 'Content'); 
      return $fields;

Code 2: (mysite/code/Sidebar.php)


class Sidebar extends Page {
   static $db = array();
   static $has_one = array();

class Sidebar_Controller extends Page_Controller {



Code 3: (themes/n1/templates/

<p>Start Sidebar</p>
				<% control Sidebar %>
				   <div id="contentright">
				      sidebar Content: $Content
				<% end_control %>