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 /

Sidebar content/editable regions help (please)


Go to End
Reply


12 Posts   3874 Views

Avatar
Willr

Forum Moderator, 5513 Posts

24 November 2009 at 11:25am

I take it in this case the file I am working with is "mysite/code/HomePage.php"?

Yes, if you only want this region for the homepage then you will just use the HomePage.php file. Copy the $db array and getCMSFields() from the code I posted and use that in the HomePage.php

Avatar
arthurdent

Community Member, 184 Posts

24 November 2009 at 3:18pm

Terrific Will -- that cracked it!! Thanks heaps!!

Avatar
arthurdent

Community Member, 184 Posts

19 June 2013 at 10:25am

Edited: 19/06/2013 10:25am

Revisiting the post to try to get an editable sidebar working in SS3...

Discovered that "Root.Content.Sidebar" is deprecated in Version 3. PHP code needs to change to the following...

<?php

class Page extends SiteTree {

static $db = array(
'SidebarHTML' => 'HTMLText'
);

static $has_one = array(
);

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Sidebar", new HtmlEditorField( "SidebarHTML"));
return $fields;

}

}

class Page_Controller extends ContentController {

}
?>

Hopefully this will help others in a similar predicament!

Avatar
arthurdent

Community Member, 184 Posts

19 June 2013 at 10:37am

Just one thing weird I've noticed -- the CMS doesn't seem to appreciate my efforts very much. However all page content is written to DB and a refresh solves the CMS interface issues... however it gets pretty ugly for a moment!

Anybody have any ideas about what's going on?

Go to Top