Magento XML files


Magento keeps a lot of configurations in xml files.

For example:

1. Activation of a module

2. Module configuration

3. Layout configurations

The most simple example are xml files for module activation and look like this:

<!--?xml version="1.0"?-->

Tag active can have to possible values: true or false. If is set to true module is active, and if is set to false, or this xml not exist, module is disabled and it will not be loaded by magento.

Tag codePool it tell to magento in wich folder module is located. Possible values are local (ussually), community, or core.

Tags depends is optional and tells magento that module is dependend of other modules, and that module must exist and active. Next category of magento xml file types are module xml configuration files. Below is an example:

<!--?xml version="1.0"?-->

Each magento module must have in module folder structure, under etc directory, at least one xml file configuration, like one listed above, if configuration file not exist magento will not know what to load from our module.

Tag config represents root node for magento module configuration. Under tags modules ca be defined module version, and is optional especially if our module hasn't an install script.

Under the global tag we define configurations for global scope. In this example we define configurations for model, blocks and helpers. Under this tags usually, we defined how our modules, blocks and helper can be called from other any part of magento code, or we define what models, blocks and helper want to rewrite and with and with whom. This config file can be more complex, but for this example i thing that is best to use a simplified one. Next type of magento xml configuration are layout's configurations files, like this one:

<!--?xml version="1.0"?-->
<layout version="0.1.0">
         <reference name="root">
            <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
        <reference name="content">
            <block name="myblock" template="mymodule/myblock.phtml" type="namespace_mymodule/myblock">

In this configuration module we define an custom handler for our module named "namespace_mymodule_index_index" and when this handler is called it will set a certain type of template and in content section it will render myblock content. This was a short introduction in magento xml config files. I hope in the future to write an dedicated article for each type of those files.

Add comment


Warning: Unknown: write failed: Disk quota exceeded (122) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0