I create a menu Employee on admin panel. This menu has a sub menu Manage Employees. When I click on Manage Employees I get an 404 error. The given below are my codes:
The given below is a part of my controller Location: /var/www/html/magento/app/code/local/Test/User/etc
<adminhtml>
<menu>
<user module="adminhtml">
<title>Employee</title>
<sort_order>71</sort_order>
<children>
<items module="user">
<title>Manage Employees</title>
<sort_order>0</sort_order>
<action>adminhtml/adminhtml_employee/</action>
</items>
</children>
</user>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<Test_User>
<title>Employee Module</title>
<sort_order>10</sort_order>
</Test_User>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<user>
<file>user.xml</file>
</user>
</updates>
</layout>
</adminhtml>
This is my controller Location: /var/www/html/magento/app/code/local/Test/User/controllers/Adminhtml
<?php
class Test_User_Adminhtml_EmployeeController extends Mage_Adminhtml_Controller_action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
?>
This are the block files Location: /var/www/html/magento/app/code/local/Test/User/Block/Adminhtml
<?php
class Test_User_Block_Adminhtml_Employee extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
$this->_controller = 'adminhtml_employee';
$this->_blockGroup = 'employee';
$this->_headerText = Mage::helper('employee')->__('Employee Manager');
$this->_addButtonLabel = Mage::helper('employee')->__('Add Employee');
parent::__construct();
}
}
?>
Location: /var/www/html/magento/app/code/local/Test/User/Block/Adminhtml/Employee
<?php
class Test_User_Block_Adminhtml_Employee_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('employeeGrid');
$this->setDefaultSort('id');
$this->setDefaultDir('ASC');
$this->setSaveParametersInSession(true);
}
protected function _prepareCollection()
{
$collection = Mage::getModel('user/employee')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('id', array(
'header' => Mage::helper('employee')->__('ID'),
'align' =>'right',
'width' => '10px',
'index' => 'id',
));
$this->addColumn('name', array(
'header' => Mage::helper('employee')->__('Name'),
'align' =>'left',
'index' => 'name',
'width' => '50px',
));
$this->addColumn('content', array(
'header' => Mage::helper('employee')->__('Description'),
'width' => '150px',
'index' => 'content',
));
return parent::_prepareColumns();
}
}
?>
and this is my xml file user.xml present inside my module:
<?xml version="1.0"?>
<layout version="0.1.0">
<employee_adminhtml_employee_index>
<reference name="content">
<block type="employee/adminhtml_employee" name="employee" />
</reference>
</employee_adminhtml_employee_index>
</layout>