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   1511 Views

Avatar
mhull

31 October 2008 at 5:26am Community Member, 79 Posts

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

31 October 2008 at 6:51am (Last edited: 31 October 2008 6:51am), Community Member, 712 Posts

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

31 October 2008 at 7:31am Community Member, 79 Posts

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

31 October 2008 at 9:58am Community Member, 470 Posts

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

31 October 2008 at 11:14am Community Member, 79 Posts

Excellent,

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

Thank you ever so much for your help!

Avatar
mhull

21 November 2008 at 10:31am Community Member, 79 Posts

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

Avatar
mhull

22 November 2008 at 8:47am Community Member, 79 Posts

can anyone help?