Ben,
thank you for the quick reply and the work around. Works good !
Laurent.
For the record here is the code:
$router = new Zend_Controller_Router_Rewrite();
$languageRoute = new Zend_Controller_Router_Route(':language',
array('language' => 'fr'), array('language' => 'fr|en'));
$route = new Zend_Controller_Router_Route_Static('',
array( 'module' => 'default',
'controller' => 'index',
'action' => 'index')
);
$router->addRoute('empty', $route);
$route = new Zend_Controller_Router_Route(':language',
array( 'module' => 'default',
'controller' => 'index',
'action' => 'index'
)
);
$router->addRoute('language', $route);
$defaultRoute = new
Zend_Controller_Router_Route(':module/:controller/:action/*',
array( 'module' => 'default',
'controller' => 'index',
'action' => 'index'
)
);
$router->addRoute('default', $languageRoute->chain($defaultRoute));
Ben Scholzen a écrit :
Am 08.07.2010 19:25, schrieb Laurent Melmoux:
Hi,
I'm trying to add "language route" support. I'm using the code down below :
$router = new Zend_Controller_Router_Rewrite();
$languageRoute = new Zend_Controller_Router_Route(':language',
array('language' => 'fr'), array('language' => 'fr|en'));
$defaultRoute = new
Zend_Controller_Router_Route(':module/:controller/:action/*',
array( 'module' => 'default',
'controller' => 'index',
'action' => 'index')
);
$router->addRoute('default', $languageRoute->chain($defaultRoute));
That's fine so far, nothing wrong with that.
But if there is no params or only the language code in the url, routing
doesn't work !
on routeShutdown I have
/ => All Request object param's are set to null
/fr => All Request object param's are set to null
But with a module name every thing works ok.
/fr/a-module-name => fr/a-module-name/index/index
Does any body have some advice to give me to sort this out ?
This is actually a bug, or more, a shortcoming, in the current system,
which is hardly solvable. It will be solved with the new routing system
in ZF2 tho. For the moment I'd suggest you the following to work around it:
Have one empty static route, which sets default language, module,
controller and action. Have an additional single language route which
sets default module, controller and action. After those, have you
chained route.
Hope that helps.
--
Laurent Melmoux
Conseil et Solutions Web | [email protected]
2mx - Vercors, France | http://www.2mx.fr/
Tél. | +33 (0)9 74 53 10 40