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.

Customising the CMS /

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

Adding new Tab to the Page descendant


Go to End


2 Posts   1343 Views

Avatar
sebastiankozub

Community Member, 59 Posts

17 September 2015 at 4:01am

Edited: 17/09/2015 4:12am

Why adding new Tab in the ways I put below always adds tab as a child of Content Tab? How can I add tab in the root (near Content, Settings and History)?

        $fields->addFieldToTab('Root', new Tab('ProductPhotos3', _t('ProductPage.ProductPhotos', 'Product Photos')));
        $fields->addFieldToTab('Root.ProductPhotos3', new UploadField("ProductPhotos", _t("ProductPage.ProductPhotos", "Product Photos 3")));  

or only second line also adding tab as a child of Content:

        $fields->addFieldToTab('Root.ProductPhotos3', new UploadField("ProductPhotos", _t("ProductPage.ProductPhotos", "Product Photos 3")));  

What is extra suprising for me that the code below cases that tab is NOT created and UploadField is generated inside Content tab.
Could anyone clarify the case to me?

        $fields->addFieldToTab('Root.Main', new Tab('ProductPhotos3', _t('ProductPage.ProductPhotos', 'Product Photos')));
        $fields->addFieldToTab('Root.Main.ProductPhotos3', new UploadField("ProductPhotos", _t("ProductPage.ProductPhotos", "Product Photos 3")));   

To be more precise I attached the screen below. What I'd like to achieve is having the tab showed with red arrow in the place where is the blue one:

Avatar
helenclarko

Community Member, 166 Posts

17 September 2015 at 9:04am

Hi Sebastiankozub,

I'm not sure this will help you. It's not quite what you are looking for, but you might be able to work with it.

function getSettingsFields() {
	$fields = parent::getSettingsFields();
	$fields->addFieldToTab("Root.NewTab", new TextField('Intro'));
    return $fields;
}

Of course swap out the text field for your upload filed.

The trouble with the above code is that it adds the tab into settings. Not really what you want but may point you in the right direction.

-helenclarko