1. 程式人生 > >magento 後臺 建立導航選單並設定許可權

magento 後臺 建立導航選單並設定許可權

1. 建立導航選單    模組配置檔案    <adminhtml></adminhtml> 下

    <menu>
            <topmeau>
                <title>title</title>
                <sort_order>200</sort_order>
                <children>
               

<uploadposters translate="title" module="topmeau">
                    <title>新增海報文案</title>
                    <action>uploadposters/adminhtml_index/index</action>
                    <sort_order>0</sort_order>
               
</uploadposters>
                </children>
            </topmeau>

    </menu>

2.設定許可權    <adminhtml></adminhtml> 下

    <acl>
    <resources>

    <admin>
    <children>
    <topmeau translate="title" module="topmeau">
                    <title>aaa</title>
                    <sort_order>110</sort_order>
                    <children>
                    <uploadposters>
                    <title>新增海報文案</title>
                    <sort_order>0</sort_order>
                    </uploadposters>
                    </children>
                    </topmeau>
    </children>
    </admin>
    </resources>

    </acl>

    在後臺控制器加入以下方法:

    protected function _isAllowed()
    {
        return Mage::getSingleton('admin/session')->isAllowed('topmeau/uploadposters');//從頂級選單開始一直到當前選單
    }