2

This is my xml code:

<admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <mymodule before="Mage_Adminhtml">Mynamespace_Mymodule_Adminhtml</mymodule>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    <adminhtml>
        <layout>
            <updates>
                <mymodule>
                    <file>mymodule.xml</file>
                </mymodule>
            </updates>
        </layout>
    </adminhtml>

This is my controller:

class Mynamespace_Mymodule_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_Action
{

    public function indexAction()
    {
       echo '1';
       exit();
        $this->loadLayout();
        $this->renderLayout();
    }
}

This is my layout:

 <?xml version="1.0"?>
    <layout version="0.1.0">
        <adminhtml_mymodule_shipment_index>
            <reference name="content">
                <block type="mymodule/shipment" template="mymodule/shipment.phtml" name="mymodule_shipment">
                </block>
            </reference>
        </adminhtml_mymodule_shipment_index>
    </layout>

Can you please tell me why I don't get the echo '1' exit?

Also when I access this url

<a href="<?php echo Mage::helper("adminhtml")->getUrl("mymodule/shipment/index/order_id/".$_order->getId()) ;?>">myurl</a>

I get a 404 error

2 Answers 2

1

The result of Mage::helper("adminhtml")->getUrl("mymodule/shipment/index"); is the URL: http://myhost/index.php/mymodule/shipment/index/ This URL is not an Admin route and will not match the adminthml router that you have extended.

To get the adminhtml path of your route use:

Mage::helper("adminhtml")->getUrl("adminhtml/shipment/index");

this will then generate the url: http://myhost/index.php/admin/shipment/index/

You will have to make sure that there is no other extension using this same path as this can break the functionality of that other extension (depending on which route is loaded first).

Also for adding parameters to the getUrl function you can add a second argument with an array with the parameters needed like this:

Mage::helper("adminhtml")->getUrl("adminhtml/shipment", array("order_id"=>$_order->getId())) 
0

you controller path must be Mynamespace/Mymodule/Adminhtml/Mymodule/ShipmentController

class Mynamespace_Mymodule_Adminhtml_Mymodule_ShipmentController extends Mage_Adminhtml_Controller_Action
{

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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