Custom Admin Configuration Tab Not Showing in Magento CE 2.1 – Fix Guide

adminmagento2

I am trying to add a configuration tab to the magento admin for my custom module. The problem is that the tab is not showing and no error is given.

this is my acl.xml

    <code>
    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn: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">
                                <!-- this resource id we can use in system.xml for section -->
                                <resource id="Xlii_Ekomi::config_xlii_ekomi" title="Helloworld Section" sortOrder="80" />
                            </resource>
                        </resource>
                    </resource>
                </resource>
            </resources>
        </acl>
    </config>
    </code>

and this is my system.xml

    <code>
    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
        <system>
            <!-- Add new Tab -->
            <tab id="xlii" translate="label" sortOrder="300">
                <label>Darsh Banner</label>
            </tab>
            <section id="xlii_ekomi" translate="label" type="text" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Helloworld</label>
                <tab>xlii</tab>
                <!-- resource tag name which we have to defined in the acl.xml -->
                <resource>Xlii_Ekomi::config_xlii_ekomi</resource>
            </section>
            <group id="general" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>General Options</label>
                <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Enabled</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
            </group>
        </system>
    </config>
    </code>

Best Answer

Check This Code Its Works for me:

 Vendor/<Modulename/
    ├── etc
    │   ├── acl.xml
    │   ├── adminhtml
    │   │   └── system.xml
    │   └── module.xml
    └── registration.php

acl.xml

        <?xml version="1.0"?>

        <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn: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="Vendor_Modulename::config" title="Extension config example" sortOrder="50" />
                                </resource>
                            </resource>
                        </resource>
                    </resource>
                </resources>
            </acl>
        </config>

system.xml file:

            <?xml version="1.0"?>

            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
                <system>
                    <tab id="example_tab" translate="label" sortOrder="1000">
                        <label>Example tab config</label>
                    </tab>
                    <section id="example_section" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Example config section</label>
                        <tab>example_tab</tab>
                        <resource>Vendor_Modulename::config</resource>
                        <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                            <label>General</label>

                            <field id="text_example" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
                                <label>Text example</label>
                            </field>

                            <field id="textarea_example" translate="label" type="textarea" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
                                <label>Textarea example</label>
                            </field>
                        </group>
                    </section>
                </system>
            </config>

module.xml

        <?xml version="1.0"?>

        <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
            <module name="Vendor_Modulename" setup_version="1.0.0"/>
        </config>

registration.php

  <?php

  \Magento\Framework\Component\ComponentRegistrar::register(
 \Magento\Framework\Component\ComponentRegistrar::MODULE,
 'Vendor_Modulename',
 __DIR__
);

sample answer:

enter image description here

Let me know any problem occur.

Related Topic