I am trying to create my first module in Magento.
The thing that I can’t do i sto define a module’s route in the way that I want.
I want to create a route “gateways/iphone” and it doesn’t works. Is it possible to use “/” in a route definition?
This is my module definition:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Nacho_GatewayIphone>
<version>0.1.0</version>
</Nacho_GatewayIphone>
</modules>
<frontend>
<routers>
<nacho_gatewayiphone>
<use>standard</use>
<args>
<module>Nacho_GatewayIphone</module>
<frontName>gateway_iphone</frontName>
</args>
</nacho_gatewayiphone>
</routers>
</frontend>
</config>
And it is working fine in /gateway_iphone, but if I change <frontName> value to <frontName>gateways/iphone</frontName> when I try to hit /gateways/iphone it doesn’t run.
Is it possible to use “/” character in a router definition?
Since Magento parses URL to get
router/controller/action, you can’t really specify the router with /, since it will violate the above structure.The answer is pretty easy though, why don’t you specify gateways as a router, and iphone as a controller? You still will need a controller for your module, so instead of creating
IndexController, you can createIphoneControllerwithgatewaysas a router, and get desiredgateways/iphonein the url.