Admin route in custom modules

2019-07-25 11:51发布

问题:

All stock magento modules have URL path in backend which has 'admin' (by default) part. However I was not able to achieve that for a custom module. Is this not possible or done on a purpose?

Thanks

回答1:

The first part of the URL is known as the "frontName".

http://example.magento.com/frontName/controllerName/actionName

Magento only allows a single module to claim a particular frontName. For the admin frontname, that's Adminhtml.

However, Magento 1.3 introduced a configuration syntax that allows you to a tell particular module that's already claimed a front name that it (the module) should check additional modules for controller files. This feature is often called real controller overrides, and while you can use it to replace a particular controller in Magento with your own, you can also use (and should use it) it to setup your own controllers for the admin console. The only caveat here is if Magento uses a controller name that you've already picked in a future version, you'll need to adjust things when you upgrade. (in other words, pick unique names)

If you're interested in the details, I'm in the middle of writing a series on Magento's routing engine, which will give you more detail than you'll ever need to know.