Magento

How to add admin panel Custom Menu in Magento?

By November 23, 2017 No Comments

Added a new tab in the admin panel take a look at the picture

custom1

Folder  structure:-

folder

Here is what i have in my files:-

1) IN — app/etc/modules/Shraddha_CreateAdminController.xml

<?xml version="1.0"?>

<config>

<modules>

<Shraddha_CreateAdminController>

<active>true</active>

<codePool>community</codePool>

</Shraddha_CreateAdminController>

</modules>
</config>

2)  IN– app/code/community/Shraddha/CreateAdminController/etc/config.xml

<?xml version="1.0"?>

<config>

<modules>

<Shraddha_CreateAdminController>

<version>1.0.0</version>

</Shraddha_CreateAdminController>

</modules>

<global>

<helpers>

<shraddha_createadmincontroller>

<!-- Helper definition needed by Magento -->

<class>Mage_Core_Helper</class>

</shraddha_createadmincontroller>

</helpers>

</global>

<admin>

<routers>

<adminhtml>

<args>

<modules>

<foo_bar before="Mage_Adminhtml">Shraddha_CreateAdminController_Adminhtml</foo_bar>

</modules>

</args>

</adminhtml>

</routers>

</admin>

</config>

3)  IN-app/code/community/Shraddha/CreateAdminController/etc/adminhtml.xml

<?xml version="1.0" encoding="UTF-8"?>

<config>

<menu>

<mycustomtab module="shraddha_createadmincontroller" translate="title">

<title>My Custom Tab</title>

<sort_order>100</sort_order>

<children>

<index module="shraddha_createadmincontroller" translate="title">

<title>Index Action</title>

<sort_order>1</sort_order>

<children>

<index translate="title">

<title>Index</title>

<sort_order>1</sort_order>

</index>

<list module="shraddha_createadmincontroller" translate="title">

<title>List </title>

<sort_order>2</sort_order>

<action>adminhtml/custom/List</action>

</list>

</children>

<action>adminhtml/custom</action>

</index>

<list module="shraddha_createadmincontroller" 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="shraddha_createadmincontroller">

<title>My Controller</title>

<sort_order>-100</sort_order>

<children>

<index translate="title">

<title>Index Action</title>

<sort_order>1</sort_order>

</index>

<children>

<index translate="title">

<title>Index Action</title>

<sort_order>1</sort_order>

</index>

</children>

</children>

<children>

<list translate="title">

<title>List Action</title>

<sort_order>2</sort_order>

</list>

</children>

</custom>

</children>

</admin>

</resources>

</acl>

</config>

4) IN– app/code/community/Shraddha/CreateAdminController/controllers/Adminhtml/CustomController.php

<?php
class Shraddha_CreateAdminController_Adminhtml_CustomController extends Mage_Adminhtml_Controller_Action

{

public function indexAction()

{

$this->loadLayout()

->_setActiveMenu('mycustomtab')

->_title($this->__('Index Action'));


$this->renderLayout();

}
public function listAction()

{

$this->loadLayout()

->_setActiveMenu('mycustomtab')

->_title($this->__('List Action'));

$this->renderLayout();

}

protected function _isAllowed()

{

return Mage::getSingleton('admin/session')->isAllowed('Shraddha_CreateAdminController/');

}

}

 

Leave a Reply