Zend Framework Router dynamic routes?

From your description, it seems like you're looking for a zend router chain where your partner is an optional chain.

From your description, it seems like you're looking for a zend router chain, where your partner is an optional chain. Here's a similar question, but using a hostname route : Zend Framework: get subdomain parameter from route. I adapted it to solve your problem, just put the following in your Bootstrap.

Php to initialize the routing : protected function _initRoute() { $this->bootstrap('FrontController'); $router = $this->getResource('FrontController')->getRouter(); // Default route $router->removeDefaultRoutes(); $defaultRoute = new Zend_Controller_Router_Route( ':controller/:action/*', array( 'module' => 'default', 'controller' => 'index', 'action' => 'index', ) ); $router->addRoute('default', $defaultRoute); $partnerRoute = new Zend_Controller_Router_Route( ':partner', array('partner' => 'none'), array('partner' => '^(partner1|partner2|partner3)$') ); $router->addRoute('partner', $partnerRoute->chain($defaultRoute)); } Change as you see fit. In your controllers you will only get a value for the partner parameter if it was actually specified AND valid (you will get a routing error if the partner doesn't exist)...

I use a similar process to detech lang, in my route (but with a ini file). You can use a default value for you partners parameter to make the route working without partner, and add a? To your regex.

But actually, I don't know how to avoid the double //... Hope that helps. EDIT: For your information, here is a simplified version of my route with language: routes.lang. Type = "Zend_Controller_Router_Route" routes.lang.

Route = "lang/:language/*" routes.lang.reqs. Language = "^(en|fr|nl|de)? $" routes.lang.defaults.

Language = none routes.lang.defaults. Module = default routes.lang.defaults. Controller = index routes.lang.defaults.

Action = language.

The thing is I can't use a default string for the case where I have no partner. This approach, based on mandatory string inside the route works with the route I posted. The problem seems to be at the reversed route which URL view helper uses to build urls.

– Bogdan Constantinescu Mar 17 at 9:20.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions