1

I have Mage 1.9 with my custom module installed. I have checked that the function

Mage::getUrl('mymodule/api/users/1');

return wrong url with admin path. We also use a custom path for the admin area. This is my config.xml

     <admin>
            <routers>
                <adminhtml>
                    <args>
                        <modules>
                            <Mymodule_Mymodule before="Mage_Adminhtml">Mymodule_Mymodule_Adminhtml</Mymodule_Mymodule>
                        </modules>
                    </args>
                </adminhtml>

            </routers>
        </admin>
<frontend>
        <routers>
            <mymodule>
                <use>standard</use>
                <args>
                    <module>Mymodule_Mymodule</module>
                    <frontName>mymodule</frontName>
                </args>
            </mymodule>
        </routers>

Now, calling Mage::getUrl('mymodule/api/users/1') from admin area return this url:

https://website.com/index.php/admin/mymodule/api/users/

Can anyone help?

0

I am not sure to understand what you are trying to achieve but you should look at the getUrl method definition : app/code/core/Mage/Core/Block/Abstract.php:1001.

The first param of this method should be the 'route' : i.e ỳour_router_name/your_controller_name/your_action_name. And if you want to pass param, it should be as an array in the second param of the getUrl method.

Something like : Mage::getUrl('mymodule/api/your_action_name', array('users'=>1)).

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.