Tuesday, August 4, 2015

Custom tab add in magento admin system configuration

Custom tab in magento admin system configuration :
How to create custom tab or menu from magento admin system configuration section. Easiest way to create, just need to follow below steps
We just want to create below two files, in your required place. Here my module is called ModuleName.

app\code\local\NameSpace\ModuleName\etc\system.xml
app\code\local\NameSpace\ModuleName\etc\adminhtml.xml


system.xml:


<?xml version="1.0"?>
<config>
    <tabs>
        <my_custom_tab translate="label" module="admincontact">
            <label>My Custom Tab</label>
            <sort_order>0</sort_order>
        </my_custom_tab>
    </tabs>
    <sections>
        <my_custom_section  translate="label" module="admincontact">                   
            <label>My Custom Section</label>
            <tab>my_custom_tab</tab>
            <frontend_type>text</frontend_type>
            <sort_order>0</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>           
            <groups>
                <my_custom_group translate="label">
                    <label>My Custom Group</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>0</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>

<inchoo_select translate="label">
                            <label>Your Module Has Been Display </label>
                            <comment>Source model provider Magento's default Yes/No values</comment>
                            <frontend_type>select</frontend_type>
                            <sort_order>0</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                        </inchoo_select>



                        <my_custom_field translate="label">
                            <label>My Custom Field</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>90</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment>Any comment I can set here</comment>
                            <tooltip>Field ToolTip</tooltip>
                        </my_custom_field>





 <textarea translate="label comment">
                            <label>Textarea</label>
                            <comment>Textarea with store view scope.</comment>
                            <frontend_type>textarea</frontend_type>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </textarea>


<file translate="label comment">
                            <label>File</label>
                            <comment><![CDATA[File saved in <strong><span style="color: red;">var/uploads</span></strong> folder.]]></comment>
                            <frontend_type>file</frontend_type>
                            <backend_model>adminhtml/system_config_backend_file</backend_model>
                            <upload_dir>var/uploads</upload_dir>
                            <sort_order>50</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>0</show_in_website>
                            <show_in_store>0</show_in_store>
                        </file>


<text_field translate="label comment">
                            <label>Please Input Your Text</label>
                            <comment>Text field with store view scope.</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </text_field>


                    </fields>


                </my_custom_group>
            </groups>
        </my_custom_section>
    </sections>

</config>


adminhtml.xml:

<?xml version="1.0"?>
    <config>
        <acl>
            <resources>
                <admin>
                    <children>
                        <system>
                            <children>
                                <config>
                                    <children>
                                        <my_custom_section translate="title" module="admincontact">
                                            <title>My Custom Section Section</title>
                                            <sort_order>0</sort_order>
                                        </my_custom_section>
                                    </children>
                                </config>
                            </children>
                        </system>
                    </children>
                </admin>
            </resources>
        </acl>

    </config>


To retrieve data saved in your configuration, you should use something like this:

Example :  $configValue =Mage::getStoreConfig('sectionName/groupName/fieldName');


echo $configValue = Mage::getStoreConfig('my_custom_section/my_custom_group/text_field'); 

0 comments:

Post a Comment