Create Controller for Backend Module

How to create custom controller on backend in magento?

In this extension we created two controller IndexController and GetdataController.

Note:- you can download extension from this rar_image
Note:- Firstly disable the cache from Cache Management tab and which is in System tab.
there are many steps to create this extension.
Step1:- Create Mywork_Useadmcontroller.xml file in app/etc/modules/.
where Mywork is Namespace and Useadmcontroller is Modulename.
[php]
<?xml version="1.0"?>
<config>
<modules>
<Mywork_Useadmcontroller>
<active>true</active>
<codePool>local</codePool>
</Mywork_Useadmcontroller>
</modules>
</config>
[/php]
Note:- 1) If you want to active the extensions then use true otherwise false.
2) there are three code pool (a) local (b) core (c) community
when we create our own extension then we use the local code pool.

Step2:- Now create the config.xml file in app/code/local/Mywork/Useadmcontroller/etc/
[php]
<?xml version="1.0"?>
<config>
<modules>
<Mywork_Useadmcontroller>
<version>1.0.0</version>
</Mywork_Useadmcontroller>
</modules>

<admin>
<routers>
<useadmcontroller>
<use>admin</use>
<args>
<module>Mywork_Useadmcontroller</module>
<frontName>useadmcontroller</frontName>
</args>
</useadmcontroller>
</routers>
</admin>

<adminhtml>
<menu>
<Mainmenu>
<title>Mywork</title>
<sort_order>200</sort_order>
<children>
<menu1>
<title>Use Controller</title>
<sort_order>1</sort_order>
<children>
<submenu1 module="useadmcontroller">
<title>Use Index Controller with index Action</title>
<sort_order>1</sort_order>
<action>useadmcontroller/adminhtml_index</action>
</submenu1>
<submenu2 module="useadmcontroller">
<title>Use Index Controller with mydetails Action</title>
<sort_order>2</sort_order>
<action>useadmcontroller/adminhtml_index/mydetails</action>
</submenu2>
<submenu3 module="useadmcontroller">
<title>Use Getdata Controller with index Action</title>
<sort_order>3</sort_order>
<action>useadmcontroller/adminhtml_getdata</action>
</submenu3>
<submenu4 module="useadmcontroller">
<title>Use Getdata Controller with mydetails Action</title>
<sort_order>4</sort_order>
<action>useadmcontroller/adminhtml_getdata/mydetails</action>
</submenu4>
</children>
</menu1>
</children>
</Mainmenu>
</menu>
</adminhtml>

<global>
<helpers>
<useadmcontroller>
<class>Mywork_Useadmcontroller_Helper</class>
</useadmcontroller>
</helpers>
</global>
</config>
[/php]
Note:- In the config.xml file we created the module version, backend module access through useadmcontroller and we define menu which is name is Mywork and it has “Use Controller” menu and it has 4 sub menu
(1) Use Index Controller with index Action
(2) Use Index Controller with mydetails Action
(3) Use Getdata Controller with index Action
(4) Use Getdata Controller with mydetails Action

Step3:- Now create the IndexController.php file in app/code/local/Mywork/Useadmcontroller/controllers/Adminhtml/
[php]
<?php
class Mywork_Useadmcontroller_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
{
public function indexAction() {

echo ‘Hello, Index controller with index action.’;

}

public function mydetailsAction() {

echo ‘Hello, Index controller with mydetails action.’;

}
}
?>
[/php]

Note:- In this file, we create two functions.
(1) indexAction() (2) mydetailsAction()

Step4:- Now create the GetdataController.php file in app/code/local/Mywork/Useadmcontroller/controllers/Adminhtml/
[php]
<?php
class Mywork_Useadmcontroller_Adminhtml_GetdataController extends Mage_Adminhtml_Controller_Action
{
public function indexAction() {

echo ‘Hello Getdata Controller with index action.’;

}

public function mydetailsAction() {

echo ‘Hello Getdata Controller with mydetails action.’;

}
}
?>
[/php]
Note:- In this file, we create two functions.
(1) indexAction() (2) mydetailsAction()

Step5:- Now create the Data.php file in app/code/local/Mywork/Useadmcontroller/Helper/
[php]
<?php
class Mywork_Useadmcontroller_Helper_Data extends Mage_Core_Helper_Abstract
{

}
?>
[/php]

admin_controller