Magento 1 – Load Custom Admin Template

adminhtmllayoutmoduletemplate

Developing a simple custom module, and the hardest part is getting the template to load in the admin. I'm sure I'm missing something simple (but important).

The template will not load. I believe all of the layout / config is loading properly.

The module controller is firing (proven via var_dump), and it appears that the layout is loading.

A var_dump(Mage::getSingleton('core/layout')->getUpdate()->getHandles()); produces one of the handles that seems correct: adminhtml_mymodule_index.

In app/code/local/mycompany/mymodule/etc/config.xml, I've got this bit (among others):

<adminhtml>
    <layout>
        <updates>
            <mycompany>
                <file>mymodule.xml</file>
            </mycompany>
        </updates>
    </layout>
</adminhtml>

In app/design/adminhtml/default/default/layout/mymodule.xml, I've got this:

<layout>
    <mycompany_adminhtml_mymodule_index>
        <update handle="mycompany_mymodule_index" />
        <reference name="content">
            <block type="adminhtml/template" name="mymodule" template="mymodule/index.phtml" />
        </reference>
    </mycompany_adminhtml_mymodule_index>
</layout>

The template is located at
app/design/adminhtml/default/default/template/mymodule/index.phtml
and contains some basic text just be able to prove if it loads.

I've got cache completely disabled (development environment), and have Magento in developer mode with no errors being thrown.

What am I missing? I've been able to prove that the layout file (mymodule.xml) is loading, but for some reason I cannot get the template file to load.

Best Answer

The issue is almost certainly an incorrect full action name handle. In your controller action you can dump the full action name with $this->getFullActionName().

Alternatively you can inspect the CSS class of the <body> tag and replace the - with _.

Full action name is derived from the router configuration. If you are (as you should be) piggybacking under the adminhtml frontname, your full action name will begin with adminhtml_.

Related Topic