5099 Posts in 1519 Topics by 1116 members
| Go to End | Next > | |
| Author | Topic: | 10980 Views |
-
Re: I wanna make a sidebar, but how?

12 January 2009 at 12:57am Last edited: 12 January 2009 1:09am
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.edit:
must this code not look like this?function GetSidebar() {
return DataObject::get_one("SidebarPage");
}I mean "GetSidebar()" and not just "GetSidebar", without the braces?
-
Re: I wanna make a sidebar, but how?

12 January 2009 at 1:14am
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.phpuser_error(Bad class to singleton() - SidebarPage,256)
line 85 of Core.phpsingleton(SidebarPage)
line 181 of CMSMain.phpCMSMain->generateDataTreeHints()
line 116 of CMSMain.phpCMSMain->SiteTreeAsUL()
call_user_func_array(Array,Array)
line 404 of ViewableData.phpViewableData->XML_val(SiteTreeAsUL,,1)
line 263 of .c*deleted*.CMSMain_left.ssinclude(*deleted*)
line 197 of SSViewer.phpSSViewer->process(CMSMain)
line 763 of ViewableData.phpViewableData->renderWith(Array)
line 365 of LeftAndMain.phpLeftAndMain->Left()
call_user_func_array(Array,Array)
line 404 of ViewableData.phpI deleted the server paths, dont want to write that here in the forum.
-
Re: I wanna make a sidebar, but how?

12 January 2009 at 1:27am Last edited: 12 January 2009 1:27am
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:)
-
Re: I wanna make a sidebar, but how?

12 January 2009 at 1:44am
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
<?php
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/SideBar.ss is
<% control GetSidebar %>
$SidebarText
$Image1
$Image2
$Image3
<% end_control %>
and lastly in my Page.ss is
<% include Sidebar %>I hope I forgot nothing.
-
Re: I wanna make a sidebar, but how?

12 January 2009 at 1:57am Last edited: 12 January 2009 2:00am
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?
-
Re: I wanna make a sidebar, but how?

12 January 2009 at 2:04am Last edited: 12 January 2009 2:05am
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
edit:
<% control GetSidebar %> must maybe be <% control GetSidebar() %> ?but that dont works, too.
-
Re: I wanna make a sidebar, but how?

12 January 2009 at 2:09am Last edited: 12 January 2009 2:11am
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
-
Re: I wanna make a sidebar, but how?

12 January 2009 at 2:14am Last edited: 12 January 2009 2:15am
thats weird..
in which page.ss do you have the "include"? in the templates/Page.ss or in templates/Layout/Page.ss ?
but that probably doesnt matter.anways. thank you for your help again. I will look if I find some mistake what I've done.
| 10980 Views | ||
| Go to Top | Next > |


