3

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.

2 Answers 2

6

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_.

2
  • Thank you for the answer / reply. When I var_dump the full action name, I get adminhtml_mymodule_index - that is correct, isn't it? If not, what should it be, and can you explain how this connects to the template not loading? Commented Sep 18, 2013 at 19:44
  • 2
    @cale_b You've got mycompany_adminhtml_mymodule_index as your full action name in the mymodule.xml file. According to your var_dump, that should be adminhtml_mymodule_index Commented Sep 18, 2013 at 20:08
0

Check out this article on building the adminhtml section of a custom extension. I've used it as a basis for a lot of custom build extensions.

From you comment on @benmarks answer it might be that the routing is wrong. The article outlines 2 methods of routing, one with and one without rewriting.

If you can't find the issue perhaps just rebuild the extension using the tutorial and also build the extension in a clean install of Magento to ensure no conflicts from other 3th party extensions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.