Magento Router URL - Hypertrophied Name Required

Let's say I use a user controller to have a url / interface name for

/customcategory 

Well, obviously, if I have a controller file called TestController.php and indexAction, the URL path would be

 /customcategory/test/index 

What I am trying to understand is how I rename Test Controller or modify the xml configuration file, so I may have a hyphen URL from the controller file, e.g.

 /customcategory/test-section/index 

I know that if I want /customcategory be portable, I can just change the frontend tag in the configuration file. But the site that I create will benefit from the route with a portable controller, the part that appears after the /customcategory with keywords, and I can’t get it to work, and I can’t find an example on google - as crazy as it might seem.

Thank you for your time.

+4
source share
2 answers

As far as I know, you cannot add bends in the URL to match the file name. If you are trying to get the folder structure, you can simply add additional paths to it.

For example, if you want:

 Namespace/CustomCategory/controller/test/SectionController.php 

You can do:

 /customcategory/test_section/index 
+1
source

What you are trying to do is possible with a global rewrite in your custom module. You can pass the entire incoming request /customcategory/* to a specific controller action. But you will have to manage your own route (based on the depth of your URL).

eg www.MageIgniter.com/customcategory/path1/path2

config.xml

 <global> <rewrite> <fancy_url> <from><![CDATA[/customcategory\/(.*)/]]></from> <to><![CDATA[customcategory/index/processroute/tagname/$1/]]></to> <complete>1</complete> </fancy_url> <rewrite> </global> <frontend> <routers> <tagseo> <use>standard</use> <args> <frontName>customcategory</frontName> </args> </tagseo> </routers> class MageIgniter_Customcategory_IndexController extends Mage_Core_Controller_Front_Action { public function processRoute(){ print_r($requestUri = Mage::app()->getRequest()->getRequestUri()); //path1/path2 print_r($this->getRequest()->getParam('tagname')); // path1 print_r($this->getRequest()) // do you custom logic here base on about request path explode('/', trim($requestUri,'/')) } ... 

For a working example, see the Product Tags section @ http://www.contempospace.com/bedroom-furniture/wardrobe-closets/custom-closet-systems/isa-closet-system-shelves-hanging-walk-in-reach -in-closet.html

+1
source

Source: https://habr.com/ru/post/1444178/


All Articles