0

So i'm developing an ajax application in which a controller intakes and outputs information for a user. What is the standard way to figure out the URL for the controller? I'm unsure of the best route to take.

thx.

1

Magento is using :module/:controller/:action/* routing scheme which was inherited from Zend Framework.

Assuming you are working with front controller and have following definition in your config.xml

<frontend>
    <routers>
        <yourmodule>
            <use>standard</use>
            <args>
                <module>Example_Yourmodule</module>
                <frontName>yourmodule</frontName>
            </args>
        </yourmodule>
    </routers>
</frontend>

Also assuming you have your controller in app/code/local/Example/Yourmodule/controllers/AjaxController.php

class Example_Yourmodule_AjaxController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
     // do something
    }
}

Your path would be yourmodule/ajax/index. To get the URL you can call Mage::getUrl('yourmodule/ajax/index');

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.