Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » How Do I Remove DOM CMS Tabs

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 2408 Views
  • socks
    Avatar
    Community Member
    190 Posts

    How Do I Remove DOM CMS Tabs Link to this post

    I've added DataObject Manager to my Page.php as it applies to most all classes. I'd like to remove it from one class.

    I assumed I should use a DataObject Decorator and have successfully removed other tabs from the CMS (ie Content.Metadata) this way, but haven't been able to figure out how to remove the tab I created w/ DOM on my Page.php.

    Any help is much appreciated.
    Thanks

  • Dr0gaz
    Avatar
    Community Member
    37 Posts

    Re: How Do I Remove DOM CMS Tabs Link to this post

    Hi !!

    try this:

          //Remove Fields
          $f->removeFieldFromTab("Root.Content.Main","Content");
          $f->removeByName("Behaviour");
          $f->removeByName("Content");
          $f->removeByName("Access");
          $f->removeByName("To-do");
          
          //$f->removeFieldFromTab("Root.Content", "Meta-data");
          //$f->removeFieldFromTab("Root.Content", "Main");
          //$f->removeFieldFromTab("Root.Content","GoogleSitemap");
          //$f->removeFieldFromTab('Root', 'Beahvior'); // replace the tab with MMDOM tab

  • socks
    Avatar
    Community Member
    190 Posts

    Re: How Do I Remove DOM CMS Tabs Link to this post

    Yeah, I tried both of those but neither worked. To clarify, this is what I have:

    Page.php


    // SIDEBAR IMAGES
       $manager = new ImageDataObjectManager(
          $this, // Controller
          'SidebarImages', // Source name
          'SidebarImage', // Source class
          'Attachment', // File name on DataObject
          array(// Headings
          ),
          'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
          // Filter clause
          // Sort clause
          // Join clause
       );
       $manager->setAddTitle('Image');
       $manager->allowUploadFolderSelection();
       $fields->addFieldToTab('Root.Content.SidebarImages', $manager);

    Trying to remove the tab Sidebar Images from above in DataObjectDecorator below:
    CustomBlaBlaPage.php

    <?php

    class CustomBlaBlaPage extends DataObjectDecorator {
       
       public function getCMSFields() {
        $fields = parent::getCMSFields();
        $this->extend('updateCMSFields', $fields);
        return $fields;
       }
       
       public function updateCMSFields(FieldSet $fields) {
          $fields->removeFieldFromTab('Root.Content','Metadata'); // THIS WORKS
          $fields->removeFieldFromTab('Root.Content','GoogleSitemap'); // THIS WORKS
    $fields->removeFieldFromTab('Root.Content','SidebarImages'); // THIS DOESN'T WORK
       }

    }

    Maybe I'm not going about it the right way.

  • UncleCheese
    Avatar
    4085 Posts

    Re: How Do I Remove DOM CMS Tabs Link to this post

    You're using this method wrong:

    $fields->removeFieldFromTab('Root.Content','SidebarImages'); // THIS DOESN'T WORK

    Use either:

    $fields->removeFieldFromTab('Root.Content.SidebarImages','SidebarImages');

    or, just:

    $fields->removeByName('SidebarImages');

  • socks
    Avatar
    Community Member
    190 Posts

    Re: How Do I Remove DOM CMS Tabs Link to this post

    I tried both of those as well and no go. I can easily remove SidebarImages if it's another class that extends Page, but when it extends Dataobject Decorator, it doesn't work.

    Thanks

  • Lou
    Avatar
    Community Member
    8 Posts

    Re: How Do I Remove DOM CMS Tabs Link to this post

    ....and two years later, I stumbled into the same problem.
    I cannot seem to remove fields from decorators. Is this a bug? I'm using version 2.4.7. Can anyone point me in the right direction?

    :: I created a post for my query: http://www.silverstripe.org/data-model-questions/show/22646

    2408 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.