2012-09-18 46 views
0

我有一个管理后端自定义控制器ACL的问题。 我已阅读,重新阅读,检查....仍然无法找到我的问题。该死。Magento自定义选项卡和管理控制器acl

首先,代码...模块本身工作...我有块,助手,前端控制器...系统 - >配置选项卡/组数据...所有工作正常。我的问题是关于admincontroller acl ...所以生病只是现在添加该地区的相关代码。

我的后端标签显示,但url(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(); 
} 

} 
+0

香港专业教育学院也被清理我的“会话”,并测试更改后的缓存'迪尔斯。 – ShaunTheSheep

+0

'adminhtml/mynewmodule /' - 从哪里空间 – doktorgradus

+0

另外...我的前端控制器路由是:/ mynewmodule/index 我的后端路由是:/ admin/mynewmodule/index 这些不能/不会冲突管理员前缀在后端? – ShaunTheSheep

回答

1

如果你写你自己的扩展,路径必须是module_name/admin_html/list。下载免费的magento扩展,例如:http://www.magentocommerce.com/magento-connect/news-by-commercelab-3436.html并查看etc/config.xml。

所以,正确的代码:

<menu> 
    <modulename module="modulename" translate="title"> 
     <title>Module Name</title> 
     <sort_order>1</sort_order> 
     <children> 
      <add translate="title" module="modulename"> 
       <title>Add New Item</title> 
       <sort_order>0</sort_order> 
       <action>modulename/adminhtml_news/new</action> 
      </add> 
      <items translate="title" module="modulename"> 
       <title>Items Manager</title> 
       <sort_order>10</sort_order> 
       <action>modulename/adminhtml_news/index</action> 
      </items> 
      <settings translate="title" module="modulename"> 
       <title>Settings</title> 
       <sort_order>40</sort_order> 
       <action>adminhtml/system_config/edit/section/modulename</action> 
      </settings> 
     </children> 
    </clnews> 
</menu> 
+2

“路径必须是'module_name/admin_html/list'“不是正确的语句(因为”必须“)。这*可以是路径,但取决于配置。 – benmarks

+1

@benmarks是正确的。如果上面的答案是正确的,这意味着配置已被更改。在原始问题上,配置使用路由器的'before'参数。看起来原来的问题是由于< Mworkz_MyNewModule_Adminhtml '之间的空格造成的。你怎么看待这件事? – ivantedja

+0

感谢您的解释。我可以在哪里阅读更多内容? (如果我的问题在本主题中被承认)。 – doktorgradus

相关问题