2

I am new to magento,I have created a custom module for magento backend. I don't know how to get its url, I have tried some help from online, nothing happens, please tell what should I pass into getUrl function.How should I use $url = Mage::helper("adminhtml")->getUrl('/your_module/index'); my file

confic.xml

<modules>
    <Petra_DailyOrders>
        <version>1.0.0</version>
    </Petra_DailyOrders>
</modules>

<global>
    <helpers>
        <petra_dailyorders>
            <!-- Helper definition needed by Magento -->
            <class>Mage_Core_Helper</class>
        </petra_dailyorders>
    </helpers>
</global>

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <petra_dailyorders before="Mage_Adminhtml">Petra_DailyOrders_Adminhtml</petra_dailyorders>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

<adminhtml>
    <layout>
        <updates>
            <petra>
                <file>dailyorders.xml</file>
            </petra>
        </updates>   
    </layout>
</adminhtml>

1
  • I tried answer given on this and other forums, I am unable to solve it, so now I came here for help. Commented Nov 13, 2015 at 7:58

1 Answer 1

3

generate it like this:

$url = Mage::helper("adminhtml")->getUrl('admintml/your_module/index');

So you should place your controller in

Petra/DailyOrders/controllers/Adminhtml/ControllerName.php and call it like this

$url = Mage::helper("adminhtml")->getUrl('admintml/controllername/index');
4
  • my controller is class Petra_DailyOrders_Adminhtml_CustomController extends Mage_Adminhtml_Controller_Action {....} and I tried as you said "$url = Mage::helper("adminhtml")->getUrl('admintml/customController/index');" it is not giving url, it is giving "marketing.com/index.php/admintml/customController/index" and original url is "marketing.com/index.php/admin/custom" Commented Nov 13, 2015 at 9:41
  • That is not a correct url Commented Nov 13, 2015 at 9:48
  • try with $url = Mage::helper("adminhtml")->getUrl('admintml/custom/index'); Commented Nov 13, 2015 at 9:58
  • already tried, it gives "marketing.com/index.php/admintml/custom/index" method is just appending the argument in front of "marketing.com/index.php" Commented Nov 13, 2015 at 10:06

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.