我正在尝试关注http://alanstorm.com/magento_admin_hello_world_revisited教程并在magento 1.9.x中设置自定义管理模块。
可下载的boilter牌http://alanstorm.com/2013/projects/Pulsestorm_Adminhello.tar正常工作。当它上传到magento时,我可以看到以下内容:
单击“示例”菜单项时,会看到一个空白页。
所以,我想现在将自己的.phtml
加载到视图中。因此,在模块config.xml
上我添加了以下内容:
应用/代码/小区/ Pulsestorm / Adminhello的/ etc / config.xml中
<?xml version="1.0"?>
<config>
...
<adminhtml>
<layout>
<updates>
<adminhello>
<file>adminhello.xml</file>
</adminhello>
</updates>
</layout>
</adminhtml>
</config>
然后我创建了以下布局xml文件:
应用/设计/ adminhtml /默认/默认/布局/ 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>
然后我创建了以下模板phtml文件:
应用/设计/ adminhtml /默认/默认/模板/ adminhello / index.phtml
<b>Hello World</b>
当我刷新页面时(Pulse Storm - &gt;示例),我仍然看到一个空白页面。我在这里缺少什么?
答案 0 :(得分:1)
这可能对您有所帮助
应用\代码\社区\ Pulsestorm \ Adminhello \等\ 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>
应用\代码\社区\ Pulsestorm \ Adminhello \块\ 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();
}
}
应用\设计\ adminhtml \默认\默认\布局\ 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>