应用\代码\本地\ STW \树\块\ Adminhtml \ Adminblock.php
<?php
class Stw_Tree_Block_Adminhtml_Adminblock extends Mage_Adminhtml_Block_Template
{
public function __construct()
{
parent::__construct();
}
protected function _prepareLayout()
{
return parent::_prepareLayout();
}
public function getHandleUpdates()
{
Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());
}
}
应用\代码\本地\ STW \树\控制器\ Adminhtml \ CustomController.php
class Stw_Tree_Adminhtml_CustomController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->_setActiveMenu('mycustomtab');
$this->renderLayout();
}
}
应用\设计\ adminhtml \默认\默认\布局\ tree.xml
<?xml version="1.0"?>
<layout>
<default>
<reference name="content">
<block type="tree/adminhtml_adminblock" name="tree" template="tree/myform.phtml" />
</reference>
</default>
</layout>
应用\代码\本地\ STW \树\等\ config.xml中
<?xml version="1.0"?>
<config>
<modules>
<Stw_Tree>
<version>1.0.0</version>
</Stw_Tree>
</modules>
<global>
<helpers>
<stw_tree>
<!-- Helper definition needed by Magento -->
<class>Mage_Core_Helper</class>
</stw_tree>
</helpers>
<blocks>
<stw_tree>
<class>Stw_Tree_Block</class>
</stw_tree>
</blocks>
</global>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<stw_tree before="Mage_Adminhtml">Stw_Tree_Adminhtml</stw_tree>
</modules>
</args>
<layout>
<updates>
<tree>
<file>tree.xml</file>
</tree>
</updates>
</layout>
</adminhtml>
</routers>
</admin>
</config>
我想在magento的admin部分加载myform.phtml,但没有任何内容正在加载。我不明白这有什么不妥。请有人告诉我改变。 myform.phtml包含纯HTML代码
答案 0 :(得分:1)
如config.xml中定义的块,如下所示: -
<blocks>
<stw_tree>
<class>Stw_Tree_Block</class>
</stw_tree>
</blocks>
您需要使用相同的别名从Layout调用此块,如下所示: -
<layout>
<default>
<reference name="content">
<block type="stw_tree/adminhtml_adminblock" name="tree" template="tree/myform.phtml" />
</reference>
</default>
</layout>
答案 1 :(得分:0)
我不相信布局节点应该在路由器注释中,就像在config.xml文件中一样。您应该将新的adminhtml节点添加为admin的兄弟节点,即config的直接子节点。
</admin>
<adminhtml>
<layout>
<updates>
<tree>
<file>tree.xml</file>
</tree>
</updates>
</layout>
</adminhtml>
</config>