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.

Archive /

Our old forums are still available as a read-only archive.

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

Problem adding Sidebar Tab to manage content


Go to End


7 Posts   1962 Views

Avatar
mhull

Community Member, 79 Posts

31 October 2008 at 5:26am

I am building up a site, and following the tutorials, but have hit a problem while trying to add a tab to the admin to manage the sidebar content.

The following code works, showing the Tab, but won't let me save a page instead showing 'Error showing content'. Is there anything very obviously I am doing wrong?

class Page extends SiteTree {
	static $db = array(
			'Sidebarcontent' => 'Content'
	);
	static $has_one = array(
   		);
   function getCMSFields() {
   $fields = parent::getCMSFields();
   
   $fields->addFieldToTab('Root.Content.Sidebar', new TextareaField('Sidebarcontent'), 'Content');
   
   return $fields;
}
}

Avatar
Hamish

Community Member, 712 Posts

31 October 2008 at 6:51am

Edited: 31/10/2008 6:51am

The problem is this link:

'Sidebarcontent' => 'Content'

The piece on the right must either be a core data type or existing data object of some sort.

Try changing it to:

'Sidebarcontent' => 'HTMLText'

Avatar
mhull

Community Member, 79 Posts

31 October 2008 at 7:31am

Thanks for your answer, this meant that it would save. But the content isn't showing up on the page, and when I return to the tab I have made the content disappears

Any ideas? I was following the tutorial movie, and trying to edit it accordingly.

Avatar
Liam

Community Member, 470 Posts

31 October 2008 at 9:58am

The content disappears or the Sidebarcontent does?

After you make the changes, run /db/build?flush=1 on your domain URL.

Then call the content in your template using the variable $Sidebarcontent

Avatar
mhull

Community Member, 79 Posts

31 October 2008 at 11:14am

Excellent,

All working! It was because I hadn't run /db/build?flush=1.

Thank you ever so much for your help!

Avatar
mhull

Community Member, 79 Posts

21 November 2008 at 10:31am

How would I get the sidebar to accept images?
At the moment it is just showing the link to the image.

Avatar
mhull

Community Member, 79 Posts

22 November 2008 at 8:47am

can anyone help?