Magento Forum

   
Customizing adminhtml - url rewrite
 
kohril
Member
 
Total Posts:  44
Joined:  2007-12-23
Lille, northernFrance
 

I made a custom module that adds a menu in admin backend.

Here are the most important lines of my module’s config.xml :

<config>
        <
modules>
        <
Mage_MonCatalogue>
            <
version>1.0</version>
        </
Mage_MonCatalogue>
    </
modules>

    <
frontend>
        <
routers>
            <
moncatalogue>
                <use>
standard</use>
                <
args>
                    <
module>Mage_MonCatalogue</module>
                    <
frontName>moncatalogue</frontName>
                </
args>
            </
moncatalogue>
        </
routers>
    </
frontend>

    <
adminhtml>
        <
menu>
            <
moncatalogue translate="title" module="moncatalogue">
                <
title>Mon Catalogue</title>
                <
sort_order>30</sort_order>
                <
children>
                    <
produits translate="title" module="moncatalogue">
                        <
title>Gérer mes produits</title>
                        <
action>moncatalogue/adminhtml_produit/</action>
                    </
produits>
                 ..........
                 ..........
</
config>

So, when I clic the menu, the page has the URL http://myserver/magento/moncatalogue/adminhtml_produit.

I’d like to rewrite that URL in order to call something like http://myserver/magento/admin/moncatalogue_produit/.

I tried to change action tag to :

<action>adminhtml/moncatalogue_produit/</action>

And added those lines :

<rewrite>
            <
moncatalogue_produit>
                <
from><![CDATA[#^/admin/moncatalogue_produit/$#]]></from>
                
<to>/moncatalogue/adminhtml_produit/</to>
            </
moncatalogue_produit>
    </
rewrite>

But it does not work. I also tried other things but it didn’t work either.

Could anyone tell me what is the proper way to do that URL rewrite ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jonathan Hedrén
Member
 
Total Posts:  67
Joined:  2007-08-31
Sweden
 

I think you’ll make it work by replacing <frontend>...</frontend> with <admin>...</admin>.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kohril
Member
 
Total Posts:  44
Joined:  2007-12-23
Lille, northernFrance
 

I’ve just tried and it does not work :

<admin>
        <
routers>
            <
moncatalogue>
                <use>
standard</use>
                <
args>
                    <
module>Mage_MonCatalogue</module>
                    <
frontName>moncatalogue</frontName>
                </
args>
            </
moncatalogue>
        </
routers>
    </
admin>

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jonathan Hedrén
Member
 
Total Posts:  67
Joined:  2007-08-31
Sweden
 

Also try changing <use>standard</use> to <use>admin</use>

 
Magento Community Magento Community
Magento Community
Magento Community
 
kohril
Member
 
Total Posts:  44
Joined:  2007-12-23
Lille, northernFrance
 

This code still does not work :

<admin>
        <
routers>
            <
moncatalogue>
                <use>
admin</use>
                <
args>
                    <
module>Mage_MonCatalogue</module>
                    <
frontName>moncatalogue</frontName>
                </
args>
            </
moncatalogue>
        </
routers>
    </
admin>

    <
adminhtml>
        <
menu>
            <
moncatalogue translate="title" module="moncatalogue">
                <
title>Mon Catalogue</title>
                <
sort_order>30</sort_order>
                <
children>
                    <
produits translate="title" module="moncatalogue">
                        <
title>Gérer mes produits</title>
                        <
action>moncatalogue/adminhtml_produit/</action>

 
Magento Community Magento Community
Magento Community
Magento Community
 
sterling
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2007-12-20
San Francisco
 

I’m also trying to figure out how to route custom module in admin screens.  I’ve seen examples for frontend, but nothing concrete for admin.

Any help would be greatly appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mark_Kimsal
Sr. Member
 
Total Posts:  186
Joined:  2007-09-12
Michigan, USA
 

@kohril
You’re doing it the same way I’m doing it, and mine works.  It’s probably a small syntax error somewhere.

You say that this URL works:
http://myserver/magento/moncatalogue/adminhtml_produit

But in the rewrite, you redirect to:
<to>/moncatalogue/adminhtml_produit/</to>

Are you sure it works both with and without a slash?  Also, delete all your cache and make sure it’s off.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kohril
Member
 
Total Posts:  44
Joined:  2007-12-23
Lille, northernFrance
 

I tried without the ending slash and it still does not work ... :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mark_Kimsal
Sr. Member
 
Total Posts:  186
Joined:  2007-09-12
Michigan, USA
 

this is my xml

<?xml version="1.0"?>
<config>
   <
modules>
      <
Metrof_AdminRest>
         <
version>0.1.00</version>
         <
depends>
            <
Mage_Adminhtml />
         </
depends>
      </
Metrof_AdminRest>
   </
modules>

    <global>
        <
rewrite>
            <
metrof_adminrest_order_export>
                <
from><![CDATA[#^/admin/order_export/$#]]></from>
                
<to>/adminrest/order_export/</to>
            </
metrof_adminrest_order_export>
        </
rewrite>
    </global>

    <
admin>
        <
routers>
            <
adminrest>
                <use>
admin</use>
                <
args>
                    <
module>Metrof_AdminRest</module>
                    <
frontName>adminrest</frontName>
                </
args>
            </
adminrest>
        </
routers>
    </
admin>
</
config>

I can hit it with

https://server/magento/index.php/adminrest/order_export
or, with the rewrite enabled, i can hit it with
https://server/magento/index.php/admin/order_export/

 
Magento Community Magento Community
Magento Community
Magento Community
 
sterling
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2007-12-20
San Francisco
 

Mark, thank you so much.  It works for me now thanks to your example.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kohril
Member
 
Total Posts:  44
Joined:  2007-12-23
Lille, northernFrance
 

Many thanks !
I don’t really understand what I did wrong but thanks to your example it works !!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top