Magento – Why write a layout in config.xml

magento-1.9

I have a module. In config.xml i found this code:

 <frontend>
            <layout>
                <updates>
                    <subscription>
                        <file>MailChimp_Subscription.xml</file>
                    </subscription>
                </updates>
            </layout>
    </frontend>

Why we must write it? What I should do, if I want use this module in other layout?

Best Answer

Layout XML

Layout XML files can be found in app/design/frontend/[package]/[theme]/layout. Each Magento module may define its own layout XML file in the config.xml file.

<frontend>
  <layout>
    <updates>
      <mymodule>
        <file>mymodule.xml</file>
      </mymodule>
    </updates>
  </layout>
</frontend>

Before the page is rendered, Magento loads all configured layout update files and its design updates to determine which block is to be rendered at which location.

source : Complete example on layout

To know in deep read Layout Update If you are creataing template lets say for home page or checkout page than in we define the layouts in our moudle layout file like/var/www/html/psydro16/app/design/frontend/base/default/layout/mymodule.xml`

<cms_index_index translate="label">
..............
  <reference name="bottom.container">
     <block type="mymodule/mymoduletemplate" name="mymodule_mymoduletemplate" template="reviews/mymoduletemplate.phtml" />
..................
 <cms_index_index>

This way we call our module template in that layout.

Related Topic