Add custom settings in Magento admin panel

Here is a sample code showing how to easily add your own configuration settings in Magento.


Once will not hurt, we will display the result before the code to see what can be added in Magento configuration:

Source code

system.xml file content (inside etc/ folder of your extension):

<?xml version="1.0"?>
        <myconf translate="label">
            <label>My Configuration</label>
        <tab1 translate="label" module="adminhtml">
            <label>Tab #1</label>
                <general translate="label comment">
                    <comment><![CDATA[This is a <strong>global comment</strong> about my <em>configuration</em>.<br />You can specify <u>custom html</u> tags. <a href="" target="_blank">Click here for example!</a>]]></comment>
                        <text_field translate="label comment">
                            <label>Text Field</label>
                            <comment>Text field with store view scope.</comment>
                        <textarea translate="label comment">
                            <comment>Textarea with store view scope.</comment>
                        <dropdown translate="label comment">
                            <comment>Dropdown with global scope.</comment>
                        <multiple_dropdown translate="label comment">
                            <comment>Multiselect with global scope.</comment>
                        <file translate="label comment">
                            <comment><![CDATA[File saved in <strong><span style="color: red;">var/uploads</span></strong> folder.]]></comment>
                        <time translate="label comment">
                        <active translate="label comment">
                        <heading_example translate="label">
                            <label>Heading example</label>
                        <boolean translate="label comment">
                            <comment>Boolean with website scope and dependant fields when Yes is selected.</comment>
                        <dependant_text_field translate="label comment">
                            <label>Dependant Text Field</label>
                            <comment>This field depends of boolean value above.</comment>

config.xml file content (inside etc/ folder of your extension):

<?xml version="1.0"?>
                <text_field>Default value</text_field>
                <dependant_text_field>Default value</dependant_text_field>

adminhtml.xml file content (inside etc/ folder of your extension):

<?xml version="1.0"?>
                                        <title>Tab #1</title> <!-- Used in resources tree -->

Dropdown values definition:

class JR_CustomConfigExample_Model_System_Config_Source_Dropdown_Values
    public function toOptionArray()
        return array(
                'value' => 'key1',
                'label' => 'Value 1',
                'value' => 'key2',
                'label' => 'Value 2',


Source code of the extension is available here. You just have to unzip in Magento root folder, clean cache and finally log out then log in again to admin panel.

36 Responses to “Add custom settings in Magento admin panel”

  1. Bravo !

    C’est le module dans notre todolist à produire depuis maintenant trop longtemps !

    Obligé d’aller récupérer des parties de modules pour intégrer des fichiers, des listes déroulantes, etc.

    N’était pas visible sur le screen, avez-vous pensé à la config à plusieurs lignes, où il est possible de rajouter des options à la volée ? (comme les options d’un attribut par exemple)

    Frédéric MARTINEZ.

  2. jim says:

    Is it possible to have sub-option dependent comments?
    Ie. only show a comment if an option is a certain value?
    Thanks :)

  3. Jean Paul says:

    Voila!! merci pour votre post.

  4. angelo fraietta says:

    Fantastic Tutorial

  5. Zeeshan Khalid says:

    Hi Johan.
    Great tutorial works like a charm. Just one question. One your current tab1 if admin presses “Save config” I want all the data to be posted on an external link say How can i hook into Save Config and send data via AJAX.

  6. venkatesh says:

    have a great code for easily understanding how to create modules tabs in magento. but here mage/source folder already created selected arrays available how we can include in our source model like languages in dropdown box try to give reply to this.i have tried but error showing.
    thank u.

  7. Mayank Patel says:

    thanks i got good help….

  8. vipan kumar says:

    Hello Everyone,

    Can anybody tell me how i can change tab1 under sections tag. i have tried just rename it from tab1 to tab2 and logout magento after save file and then check in admin configuration it still saying 404 page not found. please give me solutions

    Thanks in advance.

                My Configuration
                Tab #1
                        <![CDATA[This is a global comment about my configuration.You can specify custom html tags. Click here for example!]]>
                                Text Field
                                Text field with store view scope.
  9. Guillaume says:

    Thank you very much ! This article is wonderful and very complete !

  10. ritz says:

    what is the code to display content on frontend side? (means how to display image and all text fields values in front side?)

  11. Chintan says:


    well how can we add custom source model.
    it always gives me this error
    Call to a member function toOptionArray() on a non-object

  12. shiva says:


    How to get these values in product details page?

  13. Vishal says:

    It is working fine.

  14. brian says:

    I need help with magento. Is it possible to add a text box into the template that can be turned on and off through the admin. This is a shopping cart 3 column wide, I want the middle column at the top, just above the product. Let me know if possible.

  15. baraa says:

    I need help with magento.
    i need add to data text field from table in database
    and i need save value text field by $value

  16. Sanjay Shankar says:

    Thanks for the tutorial. But its not working for me. i am using Magento ver. . Is there any issue with this version? Please let me know….

  17. Keval says:

    Thank you for the extension. It’s work properly.
    I want to display a database value on text field in admin module.

    Thanks in advance…….

  18. Pradeep says:

    subject :—- Including top links(login/logout sign up under Account as dropdown select values)

    I want to add login signup and login/out options inside account i.e account as dropdown menu where login , sign up and login/logout should be inside Account dropdown. Can please somebody guide me how to do this.. I tried but is default . .. Please help.. such that it should not effect the functionality . . . ..


  19. renish khunt says:

    thank you so much for sharing.

  20. renish khunt says:

    how can i get that value in front side please help.

  21. Vijay says:

    Very nice tutorial it really helped…… :)

  22. lanrosta says:

    This is an old post but it is still helpful. But, like many others who have asked previously, many folks need to know how to use the created field vars in their code. The author has left this part out and also has not responded to any of the questions regarding this aspect.

    Here’s how you do it (I got this info from here: bottom of the page…

    Using Your Stored Config Values:

    Hopefully this additional info will help new visitors to implement their admin panel attribute variables into their code.

  23. lanrosta says:

    didn’t post my code. grrr… here it is in php….

    // the value for your text field
    $text_field_value = Mage::getStoreConfig(‘NAMESPACE/GROUP_IDENTIFIER/TEXT_FIELD’);

    // the value for your yes/no (boolean) field
    $boolean_field_value = Mage::getStoreConfig(‘NAMESPACE/GROUP_IDENTIFIER/BOOLEAN_FIELD’);

  24. axl says:

    nice tutorial, thanks…

  25. kumar harsh says:

    how to add text field on selection of yes/no

  26. deepak says:

    How to get image file on the frontend..?

    <a href="getUrl(”) ?>”><img src="”>

    but got this error:

    Access forbidden!

    You don’t have permission to access the requested object. It is either read-protected or not readable by the server.

    If you think this is a server error, please contact the webmaster.

    Error 403

  27. Priyank says:

    Facebook Tab Timeline

    In this how can I set default enable in option?

  28. dhivya priya says:

    Nice tutorial ! i installed magento with sample data.How to view the text field and text area content in the home page.

  29. Jack Hendricks says:

    Good tutorial. Setting up custom configs makes dealing with this bloated software bearable. Next best option to starting from scratch with a different framework.

  30. Dushyant Joshi says:

    Thanks for sharing. works well.

  31. Maxime says:

    Merci pour ce tuto. Je suis en train de faire un module Magento 1 et c’est juste ce que je cherchais.

Leave a Reply

* Required fields