在模块的controllers目录下创建Adminhtml目录,新建一个Controller类。
class Glamour_CustomerMessage_Adminhtml_MessageController extends Mage_Adminhtml_Controller_Action
{
//设置当前激活的菜单
protected function _initAction(){
$this->loadLayout()
->_setActiveMenu('customer/message')
->_addBreadcrumb(Mage::helper('adminhtml')->__('Customer Message'), Mage::helper('adminhtml')->__('Customer Message'));
return $this;
}
}
后台的Controller类继承自Mage_Adminhtml_Controller_Action(前台Controller继承的类是Mage_Core_Controller_Front_Action)。
在etc/config.xml加入:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<customermessage before="Mage_Adminhtml">Glamour_CustomerMessage_Adminhtml</customermessage>
</modules>
</args>
</adminhtml>
</routers>
</admin>
这样就可以使用和Magento自带的后台模块类似的url .../index.php/admin/message/来访问
自定义模块的后台controller,也可以实现rewrite后台controller。