Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Problem adding Sidebar Tab to manage content

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

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

Page: 1
Go to End
Author Topic: 1499 Views
  • mhull
    Avatar
    Community Member
    79 Posts

    Problem adding Sidebar Tab to manage content Link to this post

    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;
    }
    }

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: Problem adding Sidebar Tab to manage content Link to this post

    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'

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: Problem adding Sidebar Tab to manage content Link to this post

    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.

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: Problem adding Sidebar Tab to manage content Link to this post

    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

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: Problem adding Sidebar Tab to manage content Link to this post

    Excellent,

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

    Thank you ever so much for your help!

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: Problem adding Sidebar Tab to manage content Link to this post

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

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: Problem adding Sidebar Tab to manage content Link to this post

    can anyone help?

    1499 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.