How to get the URL of a page/section in Magento admin

后端 未结 2 1195
春和景丽
春和景丽 2021-01-14 14:56

I can\'t seem to find a definitive answer on this one. How do you get a url to a page in the admin backend?

For example, let\'s say I have a module that uses a cont

2条回答
  •  感情败类
    2021-01-14 15:29

    You are indeed intended to get the URL via $this->getUrl('mymodule/controller/action'). However, the confusion is stemming a mis-understanding of the routing system. The admin tag specifies to use the admin router, and the mymodule specifies the front name that is used in the URL. Basically you are creating your own front name. To utilize the admin front name, you need to use a controller rewrite in order to accomplish it. Something like the following:

    
        
            
                
                    
                        Your_Mymodule
                    
                
            
        
    
    

    What this does is configure the routing system to look at your controller for an appropriate action, but only if it doesn't find one on a Mage_Adminhtml controller.

    Do note that when using this rewrite, you would need to use 'adminhtml' instead of 'mymodule' in the call to getURL since your URLs would be falling under the front name setup by adminhtml.

    What you figured out is the correct solution to getting your own front name working, and will work just fine, as long as you don't care about using the admin front name. :)

提交回复
热议问题