Question

I'd like to make a menu in Layout which the items are linked to other different module.

e.g: Item "Product" linked to an action in Product Module, item "Service" linked to an action in Service Module.

It won't work when I set the 'url'=>('product/<controllerID>/<actionID>') and 'url'=>('service/<controllerID>/<actionID>') because once we're in Product module and click the menu "Service", the URL become

index.php?r=product/service/<controllerID>/<actionID>

instead of

index.php?r=service/<controllerID>/<actionID>

and it will be 404 error. (for sure, because the Service Module isn't inside Product Module but the URL makes it looks like that).

Any solution for this?

Was it helpful?

Solution

Check the createUrl() documentation :

the URL route. This should be in the format of 'ControllerID/ActionID'. If the ControllerID is not present, the current controller ID will be prefixed to the route. If the route is empty, it is assumed to be the current action. If the controller belongs to a module, the module ID will be prefixed to the route. (If you do not want the module ID prefix, the route should start with a slash '/'.)

That last line tells us everything. Best thing to do for you is start all the routes with a / :

'url'=>array('/<moduleID>/<controllerID>/<actionID>')

OTHER TIPS

Check this

'url'=>$this->createUrl('/<moduleId>/<controllerID>/<actionID>')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top