简体   繁体   中英

Custom admin backend module page in Magento 1.x - blank page (layout not loading)

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:

在此处输入图片说明

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?

This might help you

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

<?xml version="1.0"?>
<config>
  <modules>
    <Pulsestorm_Adminhello>
      <version>0.1.0</version>
    </Pulsestorm_Adminhello>
  </modules>
  <global>
    <helpers>
      <adminhello>
        <class>Pulsestorm_Adminhello_Helper</class>
      </adminhello>
    </helpers>
    <blocks>
      <adminhello>
        <class>Pulsestorm_Adminhello_Block</class>
      </adminhello>
    </blocks>
  </global>
  <admin>
    <routers>
      <adminhello>
        <use>admin</use>
        <args>
          <module>Pulsestorm_Adminhello</module>
          <frontName>admin_adminhello</frontName>
        </args>
      </adminhello>
    </routers>
  </admin>
  <adminhtml>
    <menu>
      <adminhello module="adminhello">
        <title>Adminhello</title>
        <sort_order>100</sort_order>
        <children>
          <adminhellobackend module="adminhello">
            <title>Adminhello</title>
            <sort_order>0</sort_order>
            <action>admin_adminhello/adminhtml_adminhellobackend</action>
          </adminhellobackend>
        </children>
      </adminhello>
    </menu>
    <acl>
      <resources>
        <all>
          <title>Allow Everything</title>
        </all>
        <admin>
          <children>
            <adminhello translate="title" module="adminhello">
              <title>Adminhello</title>
              <sort_order>1000</sort_order>
              <children>
          <adminhellobackend translate="title">
            <title>Adminhello</title>
          </adminhellobackend>
              </children>
            </adminhello>
          </children>
        </admin>
      </resources>
    </acl>
    <layout>
      <updates>
        <adminhello>
          <file>adminhello.xml</file>
        </adminhello>
      </updates>
    </layout>
  </adminhtml>
</config> 

app\\code\\community\\Pulsestorm\\Adminhello\\Block\\Adminhtml\\Adminhellobackend.php

<?php
class Pulsestorm_Adminhello_Adminhtml_AdminhellobackendController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
       $this->loadLayout();
       $this->_title($this->__("Adminhello"));
       $this->renderLayout();
    }
}

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

<?xml version="1.0"?>
<layout version="0.1.0">
  <adminhello_adminhtml_adminhellobackend_index>
    <reference name="content">
      <block type="adminhello/adminhtml_adminhellobackend" name="adminhellobackend" template="adminhello/adminhellobackend.phtml"/>
    </reference>
  </adminhello_adminhtml_adminhellobackend_index>
</layout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM