Layout – How to Fix Layout Not Loading Issues

layout

I am creating a module called Mdeprojects_Discount. I have added the following folders

app/local/Mdeprojects/Discount/[plus all relevant folders required]

app/design/frontend/mdediscount/default/layout/

app/design/frontend/mdediscount/default/template/discount/

In the layout folder I have added local.xml and that works as expected. My other layout file which I have in the folder is not loading when I call it, this has been checked by badly formatting the layout file, but I have received no errors. (cacheing is off, errors are on).

In my controller I have ran var_dump($this->getLayout()->getUpdate()->getHandles()) this returns an empty array. But I am using Commercebug and under the Layout tab and "Handles for this request" title, one of the handles returned is <mdeprojects_discount_remainder_remainder />

Why is commerce bug returning a handle and my command not returning anything? (i'm hoping if this is solved, it will also solve why my layout file isn't loading)

app/local/Mdeprojects/Discount/etc/config.xml

<config>
<frontend>
    <routers>
        <mdeprojects_discount>
            <use>standard</use>
            <args>
                <module>Mdeprojects_Discount</module>
                <frontName>discount</frontName>
            </args>
        </mdeprojects_discount>
    </routers>
    <layout>
        <updates>
            <mdeprojects_remainder>
                <file>mdeprojects/remainder.xml</file>
            </mdeprojects_remainder>
        </updates>
    </layout>
</frontend>
</config>

app/local/Mdeprojects/Discount/controllers/RemainderController.php

class Mdeprojects_Discount_RemainderController
    extends Mage_Core_Controller_Front_Action
{
    public function remainderAction()
    {
        var_dump($this->getLayout()->getUpdate()->getHandles());
        $this->loadLayout()->renderLayout();
    }
}

===

EDIT

===

I have tried changing my controller file to

    public function remainderAction()
{
    $this->loadLayout()->renderLayout();
    Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());
}

this also tells me that the mdeprojects_discount_remainder_remainder handle is being called. But I am still unable to work out why my layout file is not being loaded?

Best Answer

I think it should be remainder instead of mdeprojects_remainder. At least this is what I use for my extensions

<config>
<frontend>
    [...]
    <layout>
        <updates>
            <remainder>
                <file>mdeprojects/remainder.xml</file>
            </remainder>
        </updates>
    </layout>
</frontend>
</config>
Related Topic