0

I'd like to create many extensions using the same tab like this sample on the image below, what I need to do in each extension to keep at the same tab?

Stores > Settings > Configuration

enter image description here

2 Answers 2

1

Rafael, Pretty straight forward just use a consistent <tab></tab> in the system configuration between the extensions. For example:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="../../../Backend/etc/system_file.xsd">
    <system>

        <tab id="company" translate="label" sortOrder="100">
            <label>My Company Name</label>
        </tab>

       ... here you enter sections and fields etc ...


    </system>
</config>

As asked the ACL would be something as follows, please note that the Tab is not actually referenced.

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Magento_Backend::stores">
                    <resource id="Magento_Backend::stores_settings">
                        <resource id="Magento_Config::config">
                            <resource id="Company_Modulename::system_config"
title="Some Great Name" />
                        </resource>
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>

Magento by default won't show the tab if the user has no privileges to modules under it.

3
  • I guess that there is some ACL configuration that I need to do. Commented May 24, 2017 at 22:43
  • Shouldn't have to. The ACL applies to the sections not the tabs.
    – Eirik
    Commented May 24, 2017 at 22:44
  • The tab is just tab, I'll update with an acl shortly.
    – Eirik
    Commented May 24, 2017 at 22:45
1

In the system.xml file of your extension you can put a section (free gift in your example) under any tab just by adding a child node to the <section> node called <tab> and the value of it should be an id of an existing tab.

Here is an example from the core: https://github.com/magento/magento2/blob/develop/app/code/Magento/Sales/etc/adminhtml/system.xml#L16 and the tab declaration: https://github.com/magento/magento2/blob/develop/app/code/Magento/Sales/etc/adminhtml/system.xml#L10

3
  • I guess that there is some ACL configuration that I need to do. Commented May 24, 2017 at 22:44
  • How do you put a custom extensions setting pane under the General tab?
    – TheRealJAG
    Commented Sep 11, 2018 at 7:33
  • <tab>general</tab>
    – Marius
    Commented Sep 11, 2018 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.