This should be a fairly easy one, I hope. I've looked over Alan Storm's tutorial on the topic a hundred times, but still can't figure out what I'm missing. I just want to get my custom admin page to hit my controller's indexAction(), where I will then be rendering my layout, etc. For this question I'm just looking for an answer that hits my controller die statement when I click on my page in the admin.
Have already made sure:
- cache is cleared
- module is enabled and working, overall
Here's the relevant code:
app/code/local/Company/MyModule/etc/config.xml:
<config>
<modules>
<Company_MyModule>
<version>1.0.0</version>
</Company_MyModule>
</modules>
<global>
<blocks>
<mymodule>
<class>Company_MyModule_Block</class>
</mymodule>
</blocks>
<helpers>
<mymodule>
<class>Company_MyModule_Helper</class>
</mymodule>
</helpers>
</global>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<mymodule before="Mage_Adminhtml">Company_MyModule_Adminhtml</mymodule>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<adminhtml>
<menu>
<mymodule module="mymodule">
<title>My Custom Page</title>
<sort_order>100</sort_order>
<action>adminhtml/MyModule/homepage/index</action>
</mymodule>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<mymodule translate="title" module="mymodule">
<title>MyModule</title>
<sort_order>1000</sort_order>
<children>
<mymodulebackend translate="title" module="mymodule">
<title>My Custom Page</title>
</mymodulebackend>
</children>
</mymodule>
</children>
</admin>
</resources>
</acl>
</adminhtml>
</config>
app/code/local/Company/MyModule/controllers/Adminhtml/MyModule/HomepageController.php:
<?php
die();
class Company_MyModule_Adminhtml_MyModule_HomepageController extends Mage_Adminhtml_Controller_Action
{
/**
* Just a test action
*/
public function indexAction()
{
die('here');
$this->loadLayout();
$this->renderLayout();
}
}
Help greatly appreciated!
1 Answer 1
I think you have wrong in action tag when calling to your menu.
<menu>
<mymodule module="mymodule">
<title>My Custom Page</title>
<sort_order>100</sort_order>
<action>adminhtml/homepage/index</action>
</mymodule>
</menu>
Your controller should reside in:
app/code/local/Company/controllers/Adminhtml/HomepageController.php
UPDATE
Just remove "MyModule" folder and place your Homepagecontroller.php inside Adminhtml folder.
[Off topic a little]
-
Did indeed have the names mixed up. I've updated my code above based on your answer. Unfortunately I'm still getting a 404Dan Hennion– Dan Hennion2015年06月25日 01:12:11 +00:00Commented Jun 25, 2015 at 1:12
-
1Please check my updated answer.Adarsh Khatri– Adarsh Khatri2015年06月25日 01:18:16 +00:00Commented Jun 25, 2015 at 1:18
-
This is odd, I now get a 200 response and a white page, with no output (doesn't have the contents of my die). I set a breakpoint in xdebug and have confirmed it is not hitting that die statement. Very odd.Dan Hennion– Dan Hennion2015年06月25日 01:28:13 +00:00Commented Jun 25, 2015 at 1:28
-
That is because you have
die()(2 places) in your controller. Simply comment them.Adarsh Khatri– Adarsh Khatri2015年06月25日 01:28:50 +00:00Commented Jun 25, 2015 at 1:28 -
Brillaint. Thank you so much! You've been very helpful :)Dan Hennion– Dan Hennion2015年06月25日 01:59:43 +00:00Commented Jun 25, 2015 at 1:59
Explore related questions
See similar questions with these tags.