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

I wanna make a sidebar, but how?


37 Posts   13133 Views


12 January 2009 at 12:57am (Last edited: 12 January 2009 1:09am), Community Member, 28 Posts

I made that, but its still all white.

by the way. I need to make "db/build?flush=1" right?
But after db update its still all white.

must this code not look like this?

function GetSidebar() {
   return DataObject::get_one("SidebarPage");

I mean "GetSidebar()" and not just "GetSidebar", without the braces?


12 January 2009 at 1:14am Community Member, 28 Posts

when I make "GetSidebar()" with braces, then works the page.. just the admin menu has a error..

and now I get this error mail

Error: Bad class to singleton() - SidebarPage
At line 85 in *deleted*/Core.php

user_error(Bad class to singleton() - SidebarPage,256)
line 85 of Core.php

line 181 of CMSMain.php

line 116 of CMSMain.php

line 404 of ViewableData.php

line 263 of .c*deleted*

line 197 of SSViewer.php

line 763 of ViewableData.php

line 365 of LeftAndMain.php

line 404 of ViewableData.php

I deleted the server paths, dont want to write that here in the forum.

Carbon Crayon

12 January 2009 at 1:27am (Last edited: 12 January 2009 1:27am), Community Member, 598 Posts

ahh yea sorry, my bad!

I think that bad singleton error is usually a typo as well, check all the class names for SidebarPage and just make sure everything matches up etc.

if you cant find anything post your code and Ill take a look:)


12 January 2009 at 1:44am Community Member, 28 Posts

I found no more spelling mistakes

in Page.php is this code

function GetSidebar() {
   return DataObject::get_one("SidebarPage");

the code is in the class class Page_Controller extends ContentController {}

then.. in my SideBarPage.php is this code


class SidebarPage extends Page {

   static $db = array(
   'SidebarText' => Text;
   static $has_one = array(
   'Image1' => 'Image',
   'Image2' => 'Image',
   'Image3' => 'Image',
   function getCMSFields() {
   $fields = parent::getCMSFields();
   $fields->addFieldToTab('Root.Content.Main', new TextAreaField('SidebarText'), 'Content');
   $fields->addFieldToTab("Root.Content.Images", new ImageField('Image1'),'Content');
   $fields->addFieldToTab("Root.Content.Images", new ImageField('Image2'),'Content');
   $fields->addFieldToTab("Root.Content.Images", new ImageField('Image3'),'Content');
   return $fields;


class SidebarPage_Controller extends Page_Controller{



and in themes/my_template/templates/Includes/ is

<% control GetSidebar %>





<% end_control %>

and lastly in my is
<% include Sidebar %>

I hope I forgot nothing.

Carbon Crayon

12 January 2009 at 1:57am (Last edited: 12 January 2009 2:00am), Community Member, 598 Posts

ok first I missed another 2 ' on this line:

'SidebarText' => Text; should be 'Text';

also you care calling <% include Sidebar %> but you .ss file is called SideBar, but seeing as its working in the template it's probably right in your actual code?


12 January 2009 at 2:04am (Last edited: 12 January 2009 2:05am), Community Member, 28 Posts

edited all what you wrote, but its still not working, and since I edit "<% include Sidebar %>" to "<% include SideBar %>" is it again a white page.. But you are right, my .ss file is called SideBar and not Sidebar. So it must be right

<% control GetSidebar %> must maybe be <% control GetSidebar() %> ?

but that dont works, too.

Carbon Crayon

12 January 2009 at 2:09am (Last edited: 12 January 2009 2:11am), Community Member, 598 Posts

hmm, I have tested your code and it seems to work ok for me :S must be something else.......not sure what though, let me think about it


12 January 2009 at 2:14am (Last edited: 12 January 2009 2:15am), Community Member, 28 Posts

thats weird..

in which do you have the "include"? in the templates/ or in templates/Layout/ ?
but that probably doesnt matter.

anways. thank you for your help again. I will look if I find some mistake what I've done.