[英]Custom admin backend module page in Magento 1.x - blank page (layout not loading)
我正在嘗試遵循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
我添加了以下內容:
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>
然后,我創建了以下布局xml文件:
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>
然后,我創建了以下模板phtml文件:
app / design / adminhtml / default / default / template / adminhello / index.phtml
<b>Hello World</b>
刷新頁面(“ Pulse Storm->示例”)時,仍然看到空白頁面。 我在這里想念什么?
這可能對您有幫助
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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.