As a Magento developer you frequently encounter the Configuration page of Magento admin backend. But have you ever noticed how these configuration pages are created and where are those configuration options saved? If not don't worry, today I will tell you how to create an admin configuration page for you custom module. You might wonder that their is no '.phtml' involved in this configuration page. Shocked! Its ok, we have to play only with the xmls to create this functionality. So now lets start the development.
Open your app\code\local\<Namespace>\<module>\etc\system.xml
If file is not there, create one as stated below.
Now add following lines to the file:
Now add following lines to it:
Now write these lines:
Now the complete code may look like this:
But when you try to access this page at this time it may show you 'Access Denied' error. To remove this error open app\code\local\<Namespace>\<module>\etc\adminhtml.xml and write following lines:
Now logout from the admin section and login again. This is important to access this new configuration page otherwise 'Access Denied' error will continue to persist.
This is all to add new configuration page to your admin page. But now you may need to access the options that you just saved with your configuration page. To access them write:
In some cases you may need to set a default value of the options. Don't worry, we have a solution for that also. Open app\code\local\<Namespace>\<module>\etc\config.xml and add following code:
Open your app\code\local\<Namespace>\<module>\etc\system.xml
If file is not there, create one as stated below.
<?xml version="1.0" ?> <config> <tabs> <mynew_tab module="<module>" translate="label"> <label>Custom Configuration</label> <sort_order>100</sort_order> </mynew_tab> </tabs> </config>These lines will create a new tab in the left hand menu of the configuration page.
Now add following lines to the file:
<sections> <customconfig module="<module>" translate="label"> <label>Configuration</label> <!-- Name of the submenu in the 'Custom Configuration' tab --> <sort_order>200</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <!-- Whether to show the options on website page --> <show_in_store>1</show_in_store> <!-- Whether to show the options on store page --> <tab>mynew_tab</tab> </customconfig> </sections>These lines will add a new submenu to our configuration tab.
Now add following lines to it:
<sections> <customconfig module="<module>" translate="label"> ..... <groups> <!-- It will add a new group of options on the configuration page --> <custom_group translate="label"> <!-- Name of the option group --> <label>My Custom Configurations</label> <comment>This is example of custom configuration.</comment> <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> </custom_group> </groups> </customconfig> <sections>
Now write these lines:
<sections> <customconfig module="<module>" translate="label"> ..... <groups> <custom_group translate="label"> ..... <fields> <!-- This section will add new options to our group --> <custom_email translate="label tooltip comment"> <!-- New option created here --> <label>Is Enabled</label> <!-- Text to be displayed--> <frontend_type>select</frontend_type> <!-- Input type of option --> <source_model>adminhtml/system_config_source_yesno</source_model> <!-- Predefined model in core --> <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> <comment>Enable this module</comment> <!-- Help text for the option --> </custom_enabled> <custom_name translate="label tooltip comment"> <label>Sender Email</label> <frontend_type>text</frontend_type> <sort_order>1</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <comment>Email address of the user.</comment> </custom_name> </fields> </custom_group> </groups> </customconfig> </sections>
Now the complete code may look like this:
<?xml version="1.0" ?> <config> <tabs> <mynew_tab module="fancyfeedback" translate="label"> <label>Custom Configuration</label> <sort_order>100</sort_order> </mynew_tab> </tabs> <sections> <customconfig module="fancyfeedback" translate="label"> <label>Configuration</label> <sort_order>200</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <tab>mynew_tab</tab> <groups> <custom_group translate="label"> <label>My Custom Configurations</label> <comment>This is example of custom configuration.</comment> <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> <fields> <custom_enabled translate="label tooltip comment"> <label>Is Enabled</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> <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> <comment>Enable this module.</comment> </custom_enabled> <custom_email translate="label tooltip comment"> <label>Sender Email</label> <frontend_type>text</frontend_type> <sort_order>1</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <comment>Email address of the user.</comment> </custom_email> </fields> </custom_group> </groups> </customconfig> </sections> </config>
But when you try to access this page at this time it may show you 'Access Denied' error. To remove this error open app\code\local\<Namespace>\<module>\etc\adminhtml.xml and write following lines:
<?xml version="1.0" ?> <config> <acl> <resources> <admin> <children> <system> <children> <config> <children> <customconfig translate="title" module="fancyfeedback"> <title>Custom Configuration</title> <sort_order>100</sort_order> </customconfig> </children> </config> </children> </system> </children> </admin> </resources> </acl> </config>
Now logout from the admin section and login again. This is important to access this new configuration page otherwise 'Access Denied' error will continue to persist.
This is all to add new configuration page to your admin page. But now you may need to access the options that you just saved with your configuration page. To access them write:
Mage::getStoreConfig('customconfig/custom_group/custom_email');/*name of section, name of group, name of option*/
In some cases you may need to set a default value of the options. Don't worry, we have a solution for that also. Open app\code\local\<Namespace>\<module>\etc\config.xml and add following code:
<default> <customconfig> <custom_group> <custom_enabled>1</custom_enabled> <!-- Enabled by default--> <custom_email>bhardwajsonheight@gmail.com</custom_email> <!-- set default email address --> </custom_group> </customconfig> </default>
30 comments
thanx guys for your support
i learn so many things from your site
regards,
Chirag Nandaniya
Thanks Chirag:)
hi arvind,
its not working for me, not show custom configuration tab
Very nice tutorial.
Thanks for sharing.
Really enjoyable post and truly i inspired from this write up. Thanks and keep sharing.
I have read this post.It's really awesome.I have noted some point which make this post excellent. I hope you will keep continue to write other informative and interesting post.Thank you.
nice post,i like it very much,but i think u can think it in another way then,cause it will be interesting
Thank you for sharing This knowledge.Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place. Please keep it up!..
I was looking for such kind of post since a long time to understand this topic in well manner. Now I am satisfied and got lots of thing after visiting this post.
I am very glad with your blog. It’s really very interesting post full of valuable information very well written by u. The key part of this post is its descriptive way to define anything. I liked it with my heart. This post is a excellent example of such kind of thread.
Escorts in Gurgaon
How to check admin functionality .. Url for admin module ?
You need to go to System -> Configurations.
Here you can see the new tab on left hand side.
I am for the first time here. I found this board and I find It really useful & it helped me out a lot. I hope to give something back and help others like you aided me.
It’s Nice post, This post is a excellent example of such kind of story.
Bangalore Escorts
Escorts in Bangalore
Audi
A3 2005-2006
MB91F366_93C86
A3 2007-
CDC3217_97
A8 2005-
MB91F366_93C86
R8
CDC3217_97
TT 2007-
CDC3217_97
AK-47
go to System -> Configurations.
Here you can see the new tab on left hand side.
nothing happen. what will i do?
Nice Post it work fine..!!!!!!!
Nice Post it work Fine..!!!!!!!
Asalamualaikum sir i have done as u said its shown also + i have changed the module name accordingly but when i changed the value of "is enabled" to no the module still shows at front end ????
Asalamualikum
sir i have done as u said . now its shoeing at the admin side. and i have also changed the module names accordingly but when i change the value of "is enabled" to no it still shows the module at the front end ???
Arvind
many thnx for this very informative post
i find it very informative
i am very inspired to use this very informative post to write better for magento
best
Raj Patel
I use this for create custom configuration options of my website and believe it this is great tutorial for me. I have learn so many things from that. Giving thanks to you for sharing such an wonderful piece of knowledge.
Thanks for the tutorial, it's very helpful
Top 5 Cheap Magento web hosting
Hi,
Your tutorials are simply awesome...
But this one is not working for me.. i want to create a theme options page for the site. so i used the module name "Themeoptions" and my namespace is "Acodez". using capitalize text in xml file makes any issue??? since my module name is in Capitalize, i used it.. is that the reason?
i logout and login site many times..also tried clear cache, refreshing index management etc.but its not working.. :(
Please reply me..
Lots of Thanks in advance :)
Hi,
Your tutorials are just awesome. For a beginner like me, this site is very useful.
But this one is not working for me. Newly created configuration menus, sections etc are not displaying in the backend. I want to create a theme options page for this site. for that i have created a module called "Themeoptions" . since i used the capitalized name, i have used the same name for "" in the code. is that the reason for this issue??
please reply me..
A Lots Of Thanks In Advance :)
Hi,
One more thing.. I am using Magento ver. 1.9.0.1. Please reply me.....
Hi,
Its hard to guess the exact reason without having a look at the code.
But yes, Linux is case sensitive. If you are on windows, that should not be a problem.
Thanks.
Hi,
Thanks for your reply.. i deleted all my files and created a new module...this one works for me.. i have no idea abt the issue. But now its working fine.. :P
i guess its something with the spelling or something.. :P
anway thanks for your tutorial.. :)
Good to know:)
We would love to hear from you...