6

I have a custom module that is working just fine but I would like to be able to store variables in the config so I can use them in my code. (For example a default error message)

I think I can access them by using Mage::getStoreConfig('/some/path/here'); but I don't know how to add them to the modules config.xml (myname/mymodule/etc/config.xml) so that I can use them in my code?

Anyone have a clue? Thanks!

1 Answer 1

9

Reading these two articles should give you the information you need to add your own custom configuration variable, which will automatically give you a UI to enter values in the Admin.

If you want to set a default value for your new configuration variables, there's a top level config.xml node named default which will let you do that. Consider the following

<config>
    <!-- ... -->
    <default>
        <web>
            <default>
                <cms_home_page>home</cms_home_page>
                <cms_no_route>no-route</cms_no_route>
                <cms_no_cookies>enable-cookies</cms_no_cookies>
                <front>cms</front>
                <no_route>cms/index/noRoute</no_route>
                <show_cms_breadcrumbs>1</show_cms_breadcrumbs>
            </default>
        </web>
        <cms>
            <wysiwyg>
                <enabled>enabled</enabled>
            </wysiwyg>
        </cms>
    </default>
    <!-- ... -->
</config>

This structure in config.xml sets default values for the following config variables

web/default/cms_home_page
web/default/cms_no_route
web/default/cms_no_cookies
web/default/front
web/default/no_route
web/default/show_cms_breadcrumbs

cms/wysiwyg/enabled
Sign up to request clarification or add additional context in comments.

1 Comment

Alan, that's exactly what I needed. Using the default node was what I was looking for. Many thanks!

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.