我对管理后端的自定义控制器 ACL 有疑问。我已经阅读,重新阅读,检查......但仍然找不到我的问题。该死。
首先,代码……模块本身正在工作……我有块、助手、前端控制器……系统->配置选项卡/组数据……一切正常。我的问题只是与 admincontroller acl 相关......所以我现在只为该区域添加相关代码。
我的后端选项卡正在显示,但网址(admin/mynewmodule/index、admin/mynewmodule/list)转到 404 页面。
config.xml,管理路由器:
<admin>
<routers>
<adminhtml>
<args>
<modules>
<mynewmodule before="Mage_Adminhtml">
Mworkz_MyNewModule_Adminhtml
</mynewmodule >
</modules>
</args>
</adminhtml>
</routers>
</admin>
Adminhtml.xml、后端选项卡和 acl
<?xml version="1.0"?>
<config>
<menu>
<mynewmodule module="mynewmodule " translate="title">
<title>MyNewModule</title>
<sort_order>71</sort_order>
<children>
<items module="mynewmodule " translate="title">
<title>Index Action</title>
<sort_order>1</sort_order>
<action>adminhtml/mynewmodule/</action>
</items>
<list module="mynewmodule " translate="title">
<title>List Action</title>
<sort_order>2</sort_order>
<action>adminhtml/mynewmodule/list/</action>
</list>
</children>
</mynewmodule >
</menu>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<mynewmodule translate="title">
<title>MyNewModule</title>
</mynewmodule>
</children>
</config>
</children>
</system>
<mynewmodule translate="title" module="mynewmodule">
<title>MyNewModule</title>
<sort_order>-100</sort_order>
<children>
<items translate="title">
<title>Index Action</title>
<sort_order>1</sort_order>
</items>
<list translate="title">
<title>List Action</title>
<sort_order>2</sort_order>
</list>
</children>
</mynewmodule>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<mynewmodule>
<file>mworkz/mynewmodule.xml</file>
</mynewmodule>
</updates>
</layout>
</config>
管理员控制器
class Mworkz_MyNewModule_Adminhtml_MyNewModuleController extends Mage_Adminhtml_Controller_action
{
protected function _initAction() {
$this->loadLayout()
->_setActiveMenu('extbuilderpro/items')
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
return $this;
}
public function indexAction() {
$this->_initAction()
->renderLayout();
}
public function listAction() {
$this->_initAction()
->renderLayout();
}
}