简体   繁体   中英

magento custom admin module can't load the phtml layout file

I'm trying to create a custom admin module but the phtml file did not load, here is the code

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>

Anyone can figure out the problems? thanks

Where is your config.xml ??

You need to add your layout file in config.xml inside <adminhtml> tab.

Like this

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

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