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.

Archive /

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

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

Problem adding Sidebar Tab to manage content


Reply


7 Posts   1575 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 [url=http://doc.silverstripe.com/doku.php?id=data-types]data type[/url] 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?