views:

249

answers:

1

Hi!

Because of the problems I experienced here: Zend_ Controller_ Router_Exception: “xyz” is not specified

I want to have this route:

":module/:controller/:id"

and map it onto this:

":module/:controller/:action/id/$id"

Is there any possibility to do this with Zend Framework? I do not want to forward the browser to that URL. I just want to tell Zend Framework how to handle this route.

As for reasons why I would like to do this, you can find them in that linked SO question.

A: 

Yes it is possible. In my application.ini I specify my routes using regex this way:

resources.router.routes.something.type = "Zend_Controller_Router_Route_Regex"
resources.router.routes.something.route = "mymodule/mycontroller/([0-9]+)"
resources.router.routes.something.defaults.module = "mymodule"
resources.router.routes.something.defaults.controller = "mycontroller"
resources.router.routes.something.defaults.action = "myaction"
resources.router.routes.something.map.1 = "id"

I am not familiar with the ":variable" way of defining routes, but you can take from my example the ability to set default controllers, modules, and actions, without the need to explicitly define them in the url.

Mark
That does not solve my problem. I would like to map a route onto another route.In your example you create another route that statically puts the module, controller and action. I would like to keep the variables for module, controller and action.
Sebastian Hoitz
i didn't say it would solve it. i provided an example from my code which you should hopefully be able to use to base your route on, in addition to showing you it is possibly to map a route to another route. You can easily replace "mymodule/mycontroller/([0-9]+)" with "([a-zA-Z]+)/([a-zA-Z]+)/([0-9]+)" and then map 1 to module, 2 to controller, and 3 to id.
Mark