Thứ Bảy, 19 tháng 3, 2011

How to adding new menu in magento admin panel

Here I have Created a new Module to Add new tab in admin panel of magento.

My Namesapce Name is Anjan and My Module name is Systab

As you know to make a module first we need to make a .XML file with Namespace_Module name under app/etc/modules/ folder. So My File name will be Anjan_Systab.xml


Now I will write the following code inside this xml



<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Anjan_Systab>
            <active>true</active>
            <codePool>local</codePool>
        </Anjan_Systab>
    </modules>
</config>



As My CodePool is local which is written in Anjan_Systab.xml I will create a Folder with name Anjan inside app/code/local/, then again will create another folder with name Systab inside Anjan Folder.Now I will create an etc folder inside the Systab Folder. Inside the etc folder I will create config.xml and will write the following code



<?xml version="1.0"?>
<config>
    <modules>
        <Anjan_Systab>
            <version>0.1.0</version>
        </Anjan_Systab>
    </modules>
    <frontend>
        <routers>
            <systab>
                <use>standard</use>
                <args>
                    <module>Anjan_Systab</module>
                    <frontName>systab</frontName>
                </args>
            </systab>                        
        </routers>
        <layout>
            <updates>
                <systab>
                    <file>systab.xml</file>
                </systab>
            </updates>
        </layout>
    </frontend>
    <admin>
        <routers>
            <systab>
                <use>admin</use>
                <args>
                    <module>Anjan_Systab</module>
                    <frontName>systab</frontName>
                </args>
            </systab>
        </routers>
    </admin>
    <adminhtml>
        <menu>
            <systab module="systab">
                <title>My Tab</title>
                <sort_order>71</sort_order>
                <children>
                    <items module="systab">
                        <title>Manage Profile</title>
                        <sort_order>0</sort_order>
                        <action>systab/adminhtml_systab</action>
                    </items>
                </children>
            </systab>
        </menu>
        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                        <system>
                            <children>
                                <config>
                                    <children>
                                        <systab>

                                            <title>System Configuration Tab</title>

                                        </systab>
                                    </children>
                                </config>
                            </children>
                        </system>
                        <Anjan_Systab>
                            <title>System Configuration Tab</title>

                            <sort_order>10</sort_order>
                        </Anjan_Systab>
                    </children>
                </admin>
            </resources>
        </acl>
        <layout>
            <updates>
                <systab>
                    <file>systab.xml</file>
                </systab>
            </updates>
        </layout>
    </adminhtml>
    <global>
        <models>
            <systab>
                <class>Anjan_Systab_Model</class>
                <resourceModel>systab_mysql4</resourceModel>
            </systab>
            <systab_mysql4>
                <class>Anjan_Systab_Model_Mysql4</class>
                <entities>
                    <systab>
                        <table>systab</table>
                    </systab>
                </entities>
            </systab_mysql4>
        </models>
        <resources>
            <systab_setup>
                <setup>
                    <module>Anjan_Systab</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </systab_setup>
            <systab_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </systab_write>
            <systab_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </systab_read>
        </resources>
        <blocks>
            <systab>
                <class>Anjan_Systab_Block</class>
            </systab>
        </blocks>
        <helpers>
            <systab>
                <class>Anjan_Systab_Helper</class>
            </systab>
        </helpers>
    </global>
</config>

Now Clear your magento cache and login to you admin panel You can see one Tab Named My Tab has been successfully created.

Không có nhận xét nào:

Đăng nhận xét