4

I have create an extension which used frontend as well as admin end. My config code is below.

<frontend>
    <routers>
        <testimonial>
            <use>standard</use>
            <args>
                <module>Magentohelper_Testimonial</module>
                <frontName>testimonial</frontName>
            </args>
        </testimonial>
    </routers>
    <layout>
        <updates>
            <testimonial>
                <file>testimonial.xml</file>
            </testimonial>
        </updates>
    </layout>
</frontend>
<admin>
    <routers>
        <testimonial>
            <use>admin</use>
            <args>
                <module>Magentohelper_Testimonial</module>
                <frontName>testimonial_admin</frontName>
            </args>
        </testimonial>
    </routers>
</admin>

When i Call

Mage::getUrl('testimonial/index/check/');
from my phtml file, It Returns the admin url which is testimonial_admin/index/check/
From the magento wiki i got the instruction to create extension, which says this magento wiki module creation

I guess the router is matching the admin Url first.
How can i get the url of my frontend using Mage::getUrl function.?

1
  • the magento wiki clearly says <frontName>[module]</frontName> while you are adding _admin also, so you have to add the _admin under routers tag as well
    – MTM
    Commented Aug 30, 2014 at 13:29

1 Answer 1

8

The problem is that both the admin router and the frontend routers have the same node. Even if they have different frontNames. If you update your admin xml to the following:

<admin>
    <routers>
        <testimonial_admin>
            <use>admin</use>
            <args>
                <module>Magentohelper_Testimonial</module>
                <frontName>testimonial_admin</frontName>
            </args>
        </testimonial_admin>
    </routers>
</admin>

And then when you call Mage::getUrl('testimonial/index/check/'); you will get the frontend url and Mage::getUrl('testimonial_admin/index/check/'); will give you the admin urls.

7
  • :: Thanks for the solution. It worked. But from the magento wiki, it says only the [module] shouldn't it be [module]_admin ?? correct me if i am wrong.
    – Franc
    Commented Aug 30, 2014 at 12:54
  • yeah sure, I think it really does not matter as long as it is unique. Commented Aug 30, 2014 at 12:55
  • :: One last thing. so a module must have unique frontend router name and frontname as well as unique admin router name and frontname ?
    – Franc
    Commented Aug 30, 2014 at 12:59
  • yes, the xml gets merged together so that you need unique names here :) though I am a bit confused why you need them unique between frontend and admin. Commented Aug 30, 2014 at 13:01
  • @DavidManners , isn't this a bug, when a call is made from frontend, it should look in the frontend router, why is it returning of admin
    – MTM
    Commented Aug 30, 2014 at 13:30

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.