Magento管理菜单Acl

时间:2016-10-20 09:49:20

标签: magento menu acl

代码在后端添加一个新菜单。但我在新页面上有一个权限被拒绝的问题。我添加了控制器和助手。

我的adminhtml.xml

    <config>
<menu>
    <mycustomtab module="colorswitch" translate="title">
        <title>My Custom Tab</title>
        <sort_order>100</sort_order>
        <children>
            <index module="colorswitch" translate="title">
                <title>Index Action</title>
                <sort_order>1</sort_order>
                <action>adminhtml/colorswitch</action>
            </index>
            <list module="colorswitch" translate="title">
                <title>List Action</title>
                <sort_order>2</sort_order>
                <action>adminhtml/custom/list</action>
            </list>
        </children>
    </mycustomtab>
</menu>
<acl>
    <resources>
        <admin>
            <children>
                <custom translate="title" module="colorswitch">
                    <title>My Controller</title>
                    <sort_order>-100</sort_order>
                    <children>
                        <index translate="title">
                            <title>Index Action</title>
                            <sort_order>1</sort_order>
                        </index>
                        <list translate="title">
                            <title>List Action</title>
                            <sort_order>2</sort_order>
                        </list>
                    </children>
                </custom>
            </children>
        </admin>
    </resources>
</acl>

我不知道,问题出在哪里。

2 个答案:

答案 0 :(得分:0)

在菜单中你已经使用了节点

 <config>
  <menu>
    <mycustomtab module="colorswitch" translate="title">

及以下

   <acl>
    <resources>
        <admin>
            <children>
                <**custom** translate="title" module="colorswitch">

将此自定义节点更改为mycustomtab

答案 1 :(得分:0)

您的代码:

<acl>
    <resources>
    <admin>
        <children>
            <custom translate="title" module="colorswitch">
                <title>My Controller</title>
                <sort_order>-100</sort_order>
                <children>
                    <index translate="title">
                        <title>Index Action</title>
                        <sort_order>1</sort_order>
                    </index>
                    <list translate="title">
                        <title>List Action</title>
                        <sort_order>2</sort_order>
                    </list>
                </children>
            </custom>
        </children>
    </admin>
    </resources>
</acl>

应该是:

<acl>
    <resources>
    <admin>
        <children>
            <mycustomtab translate="title" module="colorswitch">
                <title>My Controller</title>
                <sort_order>-100</sort_order>
                <children>
                    <index translate="title">
                        <title>Index Action</title>
                        <sort_order>1</sort_order>
                    </index>
                    <list translate="title">
                        <title>List Action</title>
                        <sort_order>2</sort_order>
                    </list>
                </children>
            </mycustomtab>
        </children>
    </admin>
    </resources>
</acl>