magento自定义管理模块无法加载phtml布局文件

时间:2014-04-09 07:27:10

标签: magento

我正在尝试创建自定义管理模块但是没有加载phtml文件,这里是代码

Controller.php这样

<?php 
class TempName_AdminLog_Adminhtml_AdminLogController extends Mage_Adminhtml_Controller_Action
{

    public function indexAction()
    {
            //$this->loadLayout()->_setActiveMenu('AdminLog/items');
            $this->loadLayout();
            $this->renderLayout();

            var_dump(Mage::getSingleton('core/layout')->getUpdate()->getHandles());
die();

            //echo "abc";
    }   

}

adminhtml.xml

<?xml version="1.0"?>
<config>
    <menu>
        <adminlog module="adminlog"  translate="title"> 
            <title>Admin Log</title>
            <sort_order>72</sort_order>     
            <children>
                <adminlog module="adminlog"  translate="title"> 


                            <title>Manage</title>
                            <sort_order>450</sort_order>
                            <action>adminlog/adminhtml_adminlog</action>

                </adminlog>
            </children>
        </adminlog>
    </menu>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <adminlog module="adminlog" >
                        <title>adminlog</title>
                        <sort_order>200</sort_order>
                    </adminlog>
                </children>
            </admin>
        </resources>
    </acl>  
    <layout>
        <updates>
            <adminlog>
                <file>adminlog.xml</file>
            </adminlog>
        </updates>
    </layout>
</config>

adminlog.xml

<?xml version="1.0"?>
<layout>
    <adminlog_adminhtml_adminlog_index>
        <update handle="adminlog_adminlog_index"/>
        <reference name="content">
            <block type="adminhtml/template" name="adminlog" template="adminlog/adminlog.phtml"/>
        </reference>
    </adminlog_adminhtml_adminlog_index>
</layout>

config.xml中

<?xml version="1.0"?>

<config>
    <modules>
        <TempName_AdminLog>
            <version>1.0.0</version>
            <title>Admin log module</title>
        </TempName_AdminLog>
    </modules>
    <global>

        <helpers>
            <adminlog>
                <class>TempName_AdminLog_Helper</class>
            </adminlog>
        </helpers>
        <default>
            <adminlog>
                <general>
                    <enable>1</enable>
                </general>
            </adminlog>
        </default>

    </global>
    <admin>
        <routers>
            <adminlog>
                <use>admin</use>
                <args>
                    <module>TempName_AdminLog</module>
                    <frontName>adminlog</frontName>
                </args>
            </adminlog>
        </routers>
    </admin>
    <layout>
        <updates>
            <adminlog>
                <file>adminlog.xml</file>
            </adminlog>
        </updates>
    </layout>
</config>

任何人都可以找出问题所在?感谢

1 个答案:

答案 0 :(得分:1)

你的config.xml ??

在哪里

您需要在config.xml标签内的<adminhtml>中添加您的布局文件。

喜欢这个

  <adminhtml>
    <layout>
      <updates>
        <demo>
          <file>demo.xml</file>
        </demo>
      </updates>
    </layout>
  </adminhtml>