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.

Themes /

Discuss SilverStripe Themes.

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

New Page Type w/ Edittable Sidebar in CMS


Go to End


2 Posts   1655 Views

Avatar
Dolza

Community Member, 10 Posts

14 January 2010 at 6:40pm

I have everything in here working except displaying the contents of the sidebar itself, i think i am missing some basic functionality of how the variables are passed.

My Page:

<?php

class PageWSidebar extends SiteTree {
	
	public static $db = array("SideBar" => "HTMLText"
	);
	
	public static $has_one = array("SideBar" => "HTMLText"
	);

  function getCMSFields() {
   $fields = parent::getCMSFields();
    $fields->addFieldToTab('Root.Content.Main', new HTMLEditorField ('SideBar', 'SideBar Content'));
 return $fields;
   }
	
}

class PageWSidebar_Controller extends ContentController {
	
	public function init() {
		parent::init();

		Requirements::themedCSS("layout"); 
		Requirements::themedCSS("typography"); 
		Requirements::themedCSS("form"); 
	}

}

?>

and in my Theme I just have

<div class="foo"> $SideBar </div>

there's no errors, it just doesn't show anything that i type into the field in the cms

Avatar
Dolza

Community Member, 10 Posts

15 January 2010 at 9:50am

I had to make it's parent Page, not the tree, so problem solved.