Magento 1.x Custom Admin Module – Blank Page Issue

adminadminhtmlmagento-1.9module

I am trying to follow http://alanstorm.com/magento_admin_hello_world_revisited tutorial and setup a custom admin module in magento 1.9.x.

The downloadable boilter plate http://alanstorm.com/2013/projects/Pulsestorm_Adminhello.tar works fine. When its uploaded to magento, I can see the following:

enter image description here

When you click the Example menu item, you see a blank page.

So, I want to now load my own .phtml into the view. So, on the module's config.xml I've added the following:

app/code/community/Pulsestorm/Adminhello/etc/config.xml

<?xml version="1.0"?>
<config>
    ...
    <adminhtml>
        <layout>
            <updates>
                <adminhello>
                    <file>adminhello.xml</file>
                </adminhello>
            </updates>
        </layout>
    </adminhtml>
</config>

Then I created the following layout xml file:

app/design/adminhtml/default/default/layout/adminhello.xml

<?xml version="1.0"?>
<layout version="1.0">

    <adminhtml_adminhello_index>
        <block type="core/template" output="toHtml" name="templateBlock" template="adminhello/index.phtml">
    </adminhtml_adminhello_index>

</layout>

Then I created the following template phtml file:

app/design/adminhtml/default/default/template/adminhello/index.phtml

<b>Hello World</b>

When I refresh the page (Pulse Storm -> Example), I still see a blank page. What am I missing here?

Best Answer

To show a phtml at layout, you need to add a reference block name <refernece name="Parent_Block_name_At_Layout">

Also, your block is not closed, use / or </block>to close block.

Or you need to set your block name = root instead of templateBlock

Basically...

<?xml version="1.0"?>
<layout version="1.0">

    <adminhtml_adminhello_index>

        <block type="core/template"  name="root" template="adminhello/index.phtml"/>
    </adminhtml_adminhello_index>

</layout>

Or

<?xml version="1.0"?>
<layout version="1.0">
    <adminhtml_adminhello_index>
    <reference name="content">
        <block type="core/template"  name="templateBlock" template="adminhello/index.phtml"/>
    </reference>
    </adminhtml_adminhello_index>
</layout>

If your Magento version is 1.9.2.2 or less and have applied Magento patch supee-6788, you need to change your url process.

If you have adminhtml.xml for this extension, you need to give permission to access the page.

So, go to System > Permissions > Users. select your user and save.

Related Topic