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.

Blog Module /

Discuss the Blog Module.

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

Removing tabs from blog entry


Go to End


1245 Views

Avatar
amplifi

Community Member, 1 Post

22 June 2016 at 10:10am

Hi team.

I know what you might be thinking, this has been asked a few times here in this forum.
Problem for me is that none of the answers has worked for me, or maybe I just have not found the right answer.

What I have done.
Ok so, I have extended the Page class to have 4 has_many options;
This has been working fine for me so far. The tabs appear when editing all page types that I need.
I remove the tabs successfully on other page types that i need to remove the tabs I don't want on other page types using the below code / similar code

public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $fields->removeFieldFromTab('Root.Main', 'Content');
        $fields->removeByName('Promos');
        $fields->removeByName('Content Block Categories');
        $fields->removeByName('Content Blocks');

        return $fields;
    }

Alright, so that is fine.

I have created an extension to add a few new fields to the blog post, which has worked also, but, here is the annoying part, I cant remove any of these new tabs like above.

    public function updateCMSFields(FieldList $fields) {
        $fields->removeFieldFromTab('Root','Promos');
        $fields->removeByName('Root.Promos');
        $fields->remove('Root.Promos');
        $fields->remove('Promos');
        $fields->addFieldsToTab('blog-admin-sidebar', [
            TextField::create('YoutubeShareLink', 'Youtube Share Link'),
            DropdownField::create('ShowOnHomePage', 'Show post on home page?')
                    ->setSource(['No','Yes'])
        ]);
    }

You can see by the code above that i have tried a variety of different options to remove the Promos tab, none work, doing them one by one, or all at the same time has no effect at all.
This lead me to think, is the extension firing before the actual blog addon is, maybe it is, maybe it isnt, is this the case? and if so, how can i get it to load later, or is there something super simple that I am missing here?

Is there a better way to remove these tabs?

thanks