2

I created a module which I can see in the menu where I wanted to show it unfortunately it is not redirecting to the page, this module suppose to show the Grid I also enabled and write down the module in app/etc/modules and it is enabled no worry about that I am seeing the module in my menu the page it should go is:

http://website.com/index.php/report/adminhtml_report/

but it is a not found page here is the structure:

enter image description here

Report.php

class Report_ReserveMenu_Block_Adminhtml_Report extends Mage_Adminhtml_Block_Widget_Grid_Container
{
    public function __construct()
    {
        parent::__construct();
        $this->_removeButton('add');
        $this->_controller = 'adminhtml_report';
        $this->_blockGroup = 'report';
        $this->_headerText = Mage::helper('report')->__($navigation);

    }

    protected function _prepareLayout()
    {
        $this->setChild( 'grid',
            $this->getLayout()->createBlock( $this->_blockGroup.'/' . $this->_controller . '_grid',
            $this->_controller . '.grid')->setSaveParametersInSession(true) );  
        return parent::_prepareLayout();
    }
}

here is config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Report_ReserveMenu>
            <version>0.0.1</version>
        </Report_ReserveMenu>
    </modules>
    <global>
        <helpers>
            <Report_ReserveMenu>
                <class>Report_ReserveMenu_Helper</class>
            </Report_ReserveMenu>
        </helpers>  
        <blocks>
            <Report_ReserveMenu>
                <class>Report_ReserveMenu_Block</class>
            </Report_ReserveMenu>
        </blocks>
    </global>
    <adminhtml>
  <menu>
      <catalog>
          <children>
                <inventory>
        <children>
          <module name="Report_ReserveMenu">
            <title>03 Product Reserves</title>
            <sort_order>100</sort_order>
            <action>report/adminhtml_report</action>
          </module>
        </children>
        </inventory>
        </children>
      </catalog>
    </menu>
        <layout>
            <updates>
                <Report_ReserveMenu>
                    <file>report_menu.xml</file>
                </Report_ReserveMenu>
            </updates>
        </layout>
 </adminhtml>
</config>

also I have the update layout in app\design\adminhtml\default\default\layout\report_menu.xml

<?xml version="1.0"?>
<layout version="0.1.0">
     <report_adminhtml_report_index>    
        <reference name="content">
            <block type="report/adminhtml_report" name="report" as="events.codes.edit.report"/>
        </reference>
</report_adminhtml_report_index>
</layout>

the controller:

class Report_ReserveMenu_Adminhtml_ReportController extends Mage_Adminhtml_Controller_action
{   
protected function _isAllowed()
    {
        return Mage::getSingleton('admin/session')->isAllowed('catalog/report/report');
    }

public function indexAction() {

    $this->loadLayout();
    $this->getLayout()->createBlock('report/adminhtml_report');// <---- then this
    $this->renderLayout();

}
public function gridAction()
    {
        $this->getResponse()->setBody(
        $this->getLayout()->createBlock('report/adminhtml_report_grid')->toHtml()
        );
    }   
}

and also the grid which doesn't seem to be wrong. please tell me what is wrong with this module, if you need to see other files just let me know and I will update the question, I don't want somebody to create me a nice module and say ok use this I wanna know my problem because everytime I have the problem creating my own module and I have to copy paste some other module like a goooooof

  • extends Mage_Adminhtml_Controller_action should be extends Mage_Adminhtml_Controller_Action – seanbreeden Feb 5 '15 at 21:27
  • I also changed it to Action no result – Nickool Feb 5 '15 at 21:50
1

You're missing your admin router in config.xml

<config>

...

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <report_reservemenu before="Mage_Adminhtml">Report_ReserveMenu_Adminhtml</report_reservemenu>
                </modules>
            </args>
        </adminhtml>
    </routers>
 </admin>

 ...

 </config>

EDIT:

Also change in config.xml:

In the router, change before to after:

 after="Mage_Adminhtml"

And change:

 <title>03 Product Reserves</title>
 <sort_order>100</sort_order>
 <action>adminhtml/report</action>

The url in the admin menu will be: /admin/report/index

You can verify that your admin router is working by going to controllers/Adminhtml/ReportController.php and editing your indexAction like this:

public indexAction() {

     echo 'THIS WORKS';
     exit();

}

When you click on the menu you'll see a blank page with only "THIS WORKS" on it.

From there you can start troubleshooting your layouts.

  • I did it, it didn't work. also I have modules which are functioning but they don't have routers – Nickool Feb 5 '15 at 21:49
  • I've never made an adminhtml extension with a router that didn't have it defined. After adding the router did you flush your cache? – seanbreeden Feb 5 '15 at 21:56
  • my cache is disabled – Nickool Feb 5 '15 at 22:02
  • See edited answer above. – seanbreeden Feb 5 '15 at 22:46
  • I tried it, it doesn't show me this works, only the not found page I knew it doesn't go to my controller because I logged there before n it didn't work i dont know why though – Nickool Feb 6 '15 at 0:46
0

There are 2 ways to define admin url in magento. Each method required a different menu <action> url. See example below

<adminhtml>
    <menu>
        <menu1 translate="title" module="customlist">
            <title>ActiveCodeline SampleModule1</title>
            <sort_order>60</sort_order>
            <children>
                <menuitem1 module="SampleModule1">
                    <title>Menu item 1</title>
                    <action>{{adminhtml/customlist}}/index</action>
                </menuitem1>

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <Company_CustomList before="Mage_Adminhtml">Foo_Bar_Adminhtml</Company_CustomList>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

Or

<adminhtml>
    <menu>
        <menu1 translate="title" module="customlist">
            <title>ActiveCodeline SampleModule1</title>
            <sort_order>60</sort_order>
            <children>
                <menuitem1 module="SampleModule1">
                    <title>Menu item 1</title>
                    <action>{{customlist}}/index</action>
                </menuitem1>


<admin>
    <routers>
        <samplemodule1>
            <use>admin</use>
            <args>
                <module>ActiveCodeline_SampleModule1</module>
                <frontname>customlist</frontname>
            </args>
        </samplemodule1>
    </routers>
</admin>
  • with doing this I just get some weird url but with mine the url seems correct with yours i have this website.com/index.php/%7B%7Breport%7D%7D/index – Nickool Feb 6 '15 at 0:44
  • Please update your question with your current config.xml – Renon Stewart Feb 6 '15 at 14:46
  • Without defining adminhtml in the <action> then it won't be an /admin/ url. – seanbreeden Feb 6 '15 at 19:37

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.