Full Module Configuration Reference

Updated . Posted . Visible to the public.
<!-- # Module Initialisation
    app/etc/modules/Namespace_ModuleName.xml -->

<config>
    <modules>
        <Namespace_ModuleName>
            <active>true</active>
            <codePool>local</codePool>
        </Namespace_ModuleName>
    </modules>
</config>

<!-- # Module Configuration
    app/code/local/Namespace/ModuleName/etc/config.xml -->

<config>

    <modules>
        <Nmespace_ModuleName>
            <version>0.0.1</version>
        </Nmespace_ModuleName>
    </modules>

    <frontend>

        <routers>
            <namespace_modulename> <!-- Group name - can be anything but this is convention (or frontname) -->
                <use>standard</use> <!-- [standard|admin] -->
                <args>
                    <module>Namespace_ModuleName</module>
                    <frontName>hiworld</frontName>
                </args>
            </namespace_modulename>
        </routers>

    </frontend>

    <global> <!-- [global|frontend|admin|adminhtml] -->

        <blocks>
            <namespace_modulename>
                <class>Namespace_ModuleName_Block</class>
            </namespace_modulename>
        </blocks>

        <!-- # Blocks
        $block = Mage::app()->getLayout()->createBlock('modulename/path_to_yourblock'); 
        app/code/local/Namespace/ModuleName/Block/Path/To/Yourblock.php
        -->

        <helpers>
            <namespace_modulename> 
                <class>Namespace_ModuleName_Helper</class>
            </namespace_modulename>
        </helpers>

        <models>
            <namespace_modulename> 
                <class>Namespace_ModuleName_Model</class>
                <!-- TODO ResourceModel? -->
            </namespace_modulename>
        </models>

        <!-- # Models
        Create model at:
            app/code/local/Namespace/ModuleName/Model/ModelName.php
        as
            class Namespace_ModuleName_Model_ModelName extends Mage_Core_Model_Abstract {}

        Can be called with getModel():
            $model = Mage::getModel('namespace_modulename/modelname'); 
            'namespace_modulename' here is just the group name used for the model
        -->

        <resources>
            <!-- TODO I don't know how to do these -->
        </resources>

        <events>
            <event_name>
                <observers>
                    <namespace_module_event_name> <!-- Unique, this is convention -->
                       <class>Namespace_ModuleName_Model_observer</class>
                        <method>eventName</method> <!-- Anything, this is convention -->
                    </namespace_module_event_name>
                </observers>
            </event_name>
        </events>

        <!-- # Events
        Create observer at:
            app/code/local/Namespace/ModuleName/Model/Observer.php
        as
            class Namespace_Modulename_Model_Observer.php extends Mage_Core_Abstract {}

        For each observer, create a method as follows:
            public function eventName(Varien_Event_Observer $observer) {}
        -->

    </global>

</config>

Michael O'Loughlin
Last edit
Posted by Michael O'Loughlin to Magento (2013-05-24 09:26)