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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Sidebar content/editable regions help (please)


Go to End


12 Posts   5618 Views

Avatar
Willr

Forum Moderator, 5523 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
mhdesign

Community Member, 216 Posts

24 November 2009 at 3:18pm

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

Avatar
mhdesign

Community Member, 216 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
mhdesign

Community Member, 216 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