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)


Reply

12 Posts   3629 Views

Avatar
Willr

24 November 2009 at 11:25am Forum Moderator, 5511 Posts

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

24 November 2009 at 3:18pm Community Member, 166 Posts

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

Avatar
arthurdent

19 June 2013 at 10:25am (Last edited: 19 June 2013 10:25am), Community Member, 166 Posts

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

19 June 2013 at 10:37am Community Member, 166 Posts

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?