Popular Posts

Monday, 31 March 2014

Custom module layout file seems to be ignored

I have a couple of blocks that I’d like to include on multiple sites, so I’ve built a simple module to contain them. The problem I’m having is that the custom layout XML file that I’ve defined in the module’s config file appears to be ignored. If I place the XML from my custom layout in one of the existing XML layout files, I see my blocks. So I know that the module is generally working (at least that my blocks work correctly). But if I remove the block from an existing layout XML file and only have it in the my custom layout file, the block no longer appears.

Here is the relevant portion of my module’s config file (app/code/local/Abc/Affiliate/etc/config.xml): 



<?xml version="1.0"?><config>
    <modules>
        <Abc_Affiliate>
            <version>0.1.0</version>
        </Abc_Affiliate>
    </modules>
    <frontend>
        <routers>
            <affiliate>
                <use>standard</use>
                <args>
                    <module>Abc_Affiliate</module>
                    <frontName>affiliate</frontName>
                </args>
            </affiliate>
        </routers>
        <layout>
            <updates>
                <affiliate>
                    <file>affiliate.xml</file>
                </affiliate>
            </updates>
        </layout>
    </frontend>

    <adminhtml>
        <layout>
            <updates>
                <affiliate>
                    <file>affiliate.xml</file>
                </affiliate>
            </updates>
        </layout>
    </adminhtml>
</config>



That defines a custom layout file “affiliate.xml”. Here are the contents of that file (app/design/frontend/default/default/layout/affiliate.xml):




<?xml version="1.0"?><layout version="0.1.0">
    <default>
        <!-- Abc_Affiliate -->
        <reference name="before_body_end">
            <block type="affiliate/tracker" name="affiliate_tracker" as="affiliate_tracker" />
        </reference>
    </default>
</layout>



With the configuration set this way, I don’t see the “affiliate_tracker” block.
I’ve tried moving this portion to app/design/frontend/default/default/layout/page.xml, and then the block appears:



<reference name="before_body_end">
     <block type="affiliate/tracker" name="affiliate_tracker" as="affiliate_tracker" />
</reference>



But I don’t want to modify page.xml on multiple sites, and would like to have this layout update info in my module.

Any advice about what to change to get my module’s layout file to be recognized? Any debugging advice that may help me figure out what layout files are loaded at any particular time? 

Try adding the following file to app/etc/modules
Abc_Affiliate.xml


<config>
   <modules>
      <Abc_Affiliate>
         <active>true</active>
         <codepool>local</codepool>
      </Abc_Affiliate>
</config>


enjoy ........ :)

No comments:

Post a Comment

Magento: How to get last order id

There are many ways to get last order id:   1. From checkout session: $lastOrderId = Mage::getSingleton('checkout/session'...