Page tree
Skip to end of metadata
Go to start of metadata

app/code/(codepool)/(NameSpace)/(ModuleName)/etc/config.xml

Used to configure module. Defines all models, blocks, classes etc. for the specified module.

There is a separate config.xml file for each module. However all the files are merged together during the parsing process. This insight really helps to understand the XML structure. It is the reason that the module name is repeated as an XMLelement name (represented below as <(modulename)>) several times through every file - this is necessary to segregate configuration for each module. Without these elements, the configuration in these sections would be overwritten by the configuration files in other modules. For the same reason, it also means that it is really important to follow the Magento naming conventions for user-defined XML elements (such as, for example, <(modulename)_setup>).

XML Structure

 
  1. <config>
  2. </config>

Elements

 
ElementDescriptionExample
modulesUsed to define basic information about each module such as version number, dependencies on other modules 
global  
adminUsed to define module’s admin routers, attributes and fieldsets 
adminhtml  
install Page
frontend  
default  
stores Adminhtml
websites Adminhtml

By convention, these elements are specified as in the table above. The XML sub-structure of each element is described separately below.

modules

XML Structure

<modules>
         <(NameSpace_ModuleName)>
             <active>[true|false]</active>
             <codePool>[core|community|local]</codePool>
             <depends>
                 <(AnotherNameSpace_ModuleName) />
             </depends>
             <version>(version_number)</version>
         </(NameSpace_ModuleName)>
    </modules> 

Elements

ElementDescription
activeWhether module is active (this value can be overridden in back-end)
codePoolSpecifies subdirectory of app/code
dependsSpecifies dependencies of this module on other modules
versionDefines version of module for use with installation / upgrades

The elements activecodePool and depends are normally defined in the app/etc/modules/(NameSpace)_*.xml files, and the version element is normally defined in the module config.xml file.

global

XML Structure

<global>
        <models>
            <(modulename)>
                <class>(ClassName_Prefix)</class>
                <resourceModel>(modulename)_(resource_model_type)</resourceModel>
                <(modulename)_(resource_model_type)>
                    <!-- definition -->
                </(modulename)_(resource_model_type)>
                <rewrite><!-- definition --></rewrite>
            </(modulename)>
        </models>
        <resources>
            <(modulename)_setup><!-- definition --></(modulename)_setup>
            <(modulename)_read><!-- definition --></(modulename)_read>
            <(modulename)_write><!-- definition --></(modulename)_write>
        </resources>
        <blocks>
            <(modulename)>
                <class>(ClassName_Prefix)</class>
            </(modulename)>
        </blocks>
        <helpers>
            <(modulename)>
                <class>(ClassName_Prefix)</class>
            </(modulename)>
        </helpers>
        <fieldsets>
            <(page_handle?)>
                <(field_name)>?</(field_name)>
            </(page_handle?)>
        </fieldsets>
        <template>
            <email>
                <(email_template_name)
                    module="(modulename)"
                    translate="[label][,description]"
                    >
                    <!-- definition -->
                <(/email_template_name)>
            </email>
        </template>
        <events>
            <(event_name)>
                <observers><!-- observers --></observers>
            </(event_name)>
        </events>
        <eav_attributes><!-- definition --></eav_attributes>
        <(modulename)><!-- custom config variables --></(modulename)>
    </global> 

Elements

ElementDescription
models 
resources 
blocks 
helpers 
fieldsets 
template 
events 
eav_attributes 
(modulename)Custom config variables

admin

XML Structure

<admin>
        <attributes>
            <(attribute_name) />
        <attributes>
        <fieldsets><!-- definition --></fieldsets>
        <routers>
            <(modulename)>
                <use>[standard|admin|default]</use>
                <args>
                    <module>(NameSpace_ModuleName)</module>
                    <frontName>(frontname)</frontName>
                </args>
            </(modulename)>
            <!-- or -->
            <(modulename)>
                <args>
                    <modules>
                        <(NameSpace_ModuleName)
                            before="(AnotherNameSpace_ModuleName)"
                            >
                            (New_ClassName)
                        <(NameSpace_ModuleName)
                </args>
            </(modulename)>
        </routers>
    </admin> 

Elements

ElementDescription
attributes 
fieldsets 
routersUsed to define Magento’s router to look for the module’s controllers in the YourModule_controllers_Adminhtml before we look in the Mage_Adminhtml module for all urls that begin with /admin/controller_name

adminhtml

XML Structure

<adminhtml>
        <events>
            <(event_name)>
                <observers><!-- observers --></observers>
            </(event_name)>
        </events>
        <global_search>
            <products>
                <class>(modulename)/search_catalog</class>
                <acl>catalog</acl>
            </products>
            <customers>
                <class>adminhtml/search_customer</class>
                <acl>customer</acl>
            </customers>
            <sales>
                <class>adminhtml/search_order</class>
                <acl>sales</acl>
            </sales>
        </global_search>
        <translate>
            <modules>
                <(NameSpace_ModuleName)>
                    <files>
                        <default>(name_of_translation_file.csv)</default>
                    </files>
                </(NameSpace_ModuleName)>
            </modules>
        </translate>
        <layout>
            <updates>
                <(modulename)>
                    <file>(name_of_layout_file.xml)</file>
                </(modulename)>
            </updates>
        </layout>
        <(modulename)><!-- custom config variables --></(modulename)>
    </adminhtml> 

Elements

ElementDescription
events 
global_search 
translate 
layout 
(modulename)Custom config variables

install

XML Structure

frontend

XML Structure

<frontend>
        <secure_url>
            <(page_handle)>/relative/url</page_handle>
        </secure_url>
        <events>
            <(event_name)>
                <observers><!-- observers --></observers>
            </(event_name)>
        </events>
        <routers>
            <(modulename)>
                <use>[standard|admin|default]</use>
                <args>
                    <module>(NameSpace_ModuleName)</module>
                    <frontName>(frontname)</frontName>
                </args>
            </(modulename)>
        </routers>
        <translate>
            <modules>
                <(NameSpace_ModuleName)>
                    <files>
                        <default>(name_of_translation_file.csv)</default>
                    </files>
                </(NameSpace_ModuleName)>
            </modules>
        </translate>
        <layout>
            <updates>
                <(modulename)>
                    <file>(name_of_layout_file.xml)</
                </(modulename)>
            </updates>
        </layout>
    </frontend> 

lements

ElementDescription
secure_url 
events 
routers 
translate 
layout 

default

XML Structure

stores

XML Structure

websites

XML Structure

  • No labels