2

I have created easylife admincontroller and it configure the config.xml, and I give the Url-> protocal://Ipaddress/ics/admin/admintest but it's not displaying.

can any one tell me where I went wrong?

my code is:

Ics->EasyLife->controllers->Adminhtml->IndexController.php

<?php

class Ics_EasyLife_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }
}

Ics->EasyLife->Block->Adminhtml->Template.php

<?php
class Ics_EasyLife_Block_Adminhtml_Template extends Mage_Adminhtml_Block_Widget_Form
{
    public function MyMethod()
    {
        echo "Admin Html Page Method";
    }
}

Ics->EasyLife->etc->config.xml

<admin>
        <routers>
            <icscontroller>
                <use>admin</use>
                <args>
                    <module>Ics_EasyLife</module>
                    <frontName>admintest</frontName>
                </args>
            </icscontroller>
        </routers>
    </admin>

thanks in advance.

  • 1
    have you tried using "easylife" instead of "icscontroller" in config xml? – Stefan Gregori Oct 3 '13 at 7:03
6

I don't like that method of providing your own frontName, I prefer to overload the existing admin router because it's neat and quick. Start by changing this in your config.xml:

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <ics_easylife before="Mage_Adminhtml">Ics_EasyLife_Adminhtml</ics_easylife>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

This will make magento check for controller classes that start with Ics_EasyLife_Adminhtml before checking it's own Mage_Adminhtml. Rename your controller to Ics_EasyLife_Adminhtml_EasylifeController and rename it's corresponding file to EasylifeController.php.

Now an URL of adminhtml/easylife will expand to http://ipaddress/ics/admin/easylife/index and call your indexAction method. When making a menu entry use that URL of adminhtml/easylife. Even if you don't have any layout or blocks in place yet at least a page will show. When writing a layout use the layout handle <adminhtml_easylife_index>.

  • Does the whitespace not break the parsing of the text node into module directory arguments? – benmarks Oct 5 '13 at 14:04
  • @benmarks I didn't think so but after experimenting I see you were right. – clockworkgeek Oct 5 '13 at 14:36

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.