0

Below is my code for my menu and it does not work on my side.

config.xml

<config>
<modules>
    <MasteringMagento_Example>
        <version>1.0.0</version>
    </MasteringMagento_Example>
</modules>
<global>
    <models>
        <example>
           <class>MasteringMagento_Example_Model</class> 
        </example>
    </models>
    <blocks>
        <example>
            <class>MasteringMagento_Example_Block</class>
        </example>
    </blocks>
    <helpers>
        <example>
            <class>MasteringMagento_Example_Helper</class>
        </example>
    </helpers>
</global>

adminhtml.xml

<config>
<menu>
    <example translate="title" module="example">
        <title>Example</title>
        <sort_order>1000</sort_order>
        <action>adminhtml/example</action>
    </example>
</menu>

4

1 Answer 1

0

You know, the admin menu contains a lot of files, I'll not put all the module files, but I will help you to direct you to the right solution.

app/code/local/MasteringMagento/Example/etc/config.xml

...
</global>    
<adminhtml>
    <layout>
        <updates>
            <example>
                <file>example.xml</file>
            </example>
        </updates>
    </layout>
</adminhtml>
</config>    

app/code/local/MasteringMagento/Example/etc/adminhtml.xml

<?xml version="1.0" encoding="UTF-8"?>
    <config>
        <menu>
            <menu1 module="example" translate="title">
                <title>Menu 1</title>
                <sort_order>100</sort_order>
                <children>
                    <item1 module="example" translate="title">
                        <title>Submenu 1</title>
                        <sort_order>1</sort_order>
                        <action>adminhtml/menu/index</action>
                    </item1>
                    <item2 module="example" translate="title">
                        <title>Submenu 2</title>
                        <sort_order>2</sort_order>
                        <action>adminhtml/index/index</action>
                    </item2>
                </children>
            </menu1>
        </menu>
        <acl>
            <resources>
                <admin>
                    <children>
                        <menu1 translate="title" module="example">
                            <title>Menu 1</title>
                            <sort_order>100</sort_order>
                            <children>
                                <item1 translate="title">
                                    <title>Submenu 1</title>
                                    <sort_order>1</sort_order>
                                </item1>
                                <item2 translate="title">
                                    <title>Submenu 2</title>
                                    <sort_order>2</sort_order>
                                </item2>
                            </children>
                        </menu1>
                    </children>
                </admin>
            </resources>
        </acl>
    </config>

app/code/local/MasteringMagento/Example/controllers/Adminhtml/IndexController.php

<?php

class MasteringMagento_Example_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        $this->loadLayout()
            ->_setActiveMenu('menu/menu')
            ->_title($this->__('Submenu1'));
        $this->renderLayout();
    }
} 

app/design/adminhtml/default/default/layout/example.xml

<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
    <adminhtml_index_index>
        <reference name="content">
            <block type="exemple/adminhtml_menu" name="exemple"/>
        </reference>
    </adminhtml_index_index>
</layout>

Now you have to create all files block ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.