2

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:

  1. cache is cleared
  2. 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!

2

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]

I also have recommendation if you allow it. Not that I question @AlanStorm's authority (I would never do that :D ), for consistency reasons I think it's best yo put your admin controllers inside an Adminhtml folder.

  • Did indeed have the names mixed up. I've updated my code above based on your answer. Unfortunately I'm still getting a 404 – carbide20 Jun 25 '15 at 1:12
  • 1
    Please check my updated answer. – Adarsh Khatri Jun 25 '15 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. – carbide20 Jun 25 '15 at 1:28
  • That is because you have die() (2 places) in your controller. Simply comment them. – Adarsh Khatri Jun 25 '15 at 1:28
  • Brillaint. Thank you so much! You've been very helpful :) – carbide20 Jun 25 '15 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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