Magento – Custom admin module not showing

magento-1.6php-5.4

I have created the custom admin module, it showing empty page.

my code is:

//config.xml file

 <admin>
            <routers>
                <web>
                    <use>admin</use>
                    <args>
                        <module>Department_Web</module>
                        <frontName>web</frontName>
                    </args>
                </web>
            </routers>
        </admin>
        <adminhtml>
            <layout>
                <updates>
                    <web>
                        <file>web.xml</file>
                    </web>
                </updates>
            </layout>
        </adminhtml>
 <stores>
        <admin>
            <design>
                <package>
                    <name>default</name>
                </package>
                <theme>
                    <default>Department</default>
                </theme>
            </design>
        </admin>
    </stores>

//adminhtml.xml file

<?xml version="1.0"?>
<config>
    <menu>
        <web module="web" translate="label">
            <title>Web</title>
            <sort_order>71</sort_order>
            <children>
                <dotnet module="web" translate="label">
                    <title>Dot Net</title>
                    <sort_order>0</sort_order>
                    <action>web/adminhtml_index</action>
                </dotnet>
                <php module="web" translate="label">
                    <title>PHP</title>
                    <sort_order>1</sort_order>
                    <action>web/adminhtml_index</action>
                </php>
            </children>
        </web>
    </menu>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <Department_Web>
                        <title>Web Module</title>
                        <sort_order>10</sort_order>
                    </Department_Web>
                </children>
            </admin>
        </resources>
    </acl>
</config>

//controller file

<?php


class Department_Web_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
{
    protected function _initAction()
    {
        $this->loadLayout()->_setActiveMenu('web/set_time')->_addBreadcrumb('Web Manager','Web Manager');
        return $this;
    }

    public function indexAction()
    {
        Mage::log('c2');
        $this->_initAction();
        $this->renderLayout();
    }
}

//layout file
adminhtml->defalt->Department->layout

<?xml version="1.0"?>
<layout version="0.1.0">
    <web_adminhtml_index_index>
        <reference name="content">
            <block type="web/adminhtml_grid" name="adminhtml_web"></block>
        </reference>
    </web_adminhtml_index_index>
</layout>

looking for solution?

Thanks in advance.

Best Answer

You haven't provided all information to be able to give the correct answer. To debug, turn on the Magento developer mode (if you haven't done so already) and check the following:

1) Is web.xml being loaded?

To do so, create non-wellformed XML in the file by removing a closing tag and saving. When you reload a admin page you should see a simplexml parse error.
If you don't see the error, check
a) the layout cache is disabled,
b) the web.xml file system path and file name is correct c) the config cache has been refreshed or disabled

2) Is the block file loaded?

Check the var/log/exception.log file to see if there is a "Invalid Block Type" message in there.
If Magento is looking for a block with a class name Mage_Web_Block_Adminhtml_Grid, it means it can't resolve your block class group web/adminhtml_grid.
Add the global/blocks/web/class node to your config.xml file, with the node value Department_Web_Block.

If there is no error record in the exception.log file, add a die(__FILE__) statement outside of your class declaration to your block class. If Magento finds the file and includes it, you should see the file name as the only output when you try to reload the admin page.

3) Is your bock rendering something?

Does your block inherit the correct parent class? Depending on what you want to do it probably is one of

  • Mage_Adminhtml_Block_Widget_Grid_Container
  • Mage_Adminhtml_Block_Widget_Grid
  • Mage_Adminhtml_Block_Template
  • Mage_Adminhtml_Block_Abstract

Check a valid template file is assigned if you are extension one of the first three. If the template file doesn't exist, a page load will generate a message in the file var/log/system.log. If your block only extends the abstract block class, make sure that you implemented the _toHtml() method and that it returns a non-empty string.

The above steps should let you find the reason why Magento isn't showing what you expect.

Related Topic