Hi
I'm developing a multilingual site and, at the moment, i've setup a
multilingual route succesfully using a chain. The problem comes when i want
to add regex routes and i don't know if i'm missing something because the
route do not match.
Testing URLs:
/es/ --> works
/es/application/index/index --> works (default module is application)
/es/index --> works
/ca/index --> works
/es/michael-knight-p7764.html --> throws error as "profile" router does not
match url, so falls into "default" router and this controller does not
exists.
Here's the code i'm using:
// remove default routers
$router = Zend_Controller_Front::getInstance()->getRouter();
$router->removeDefaultRoutes();
// setup language route
$language = new Zend_Controller_Router_Route(
':language', array('language' => 'es')
);
// setup profile route (will be chained later) and add to the
// router chained with language
$profile =
new Zend_Controller_Router_Route_Regex('([a-zA-Z-]*)-p(\d+).html',
array(
'module' => 'application',
'controller' => 'profile',
'action' => 'index'
),
array(1 => 'profile', 2 => 'id'), '%s-p%d.html');
$profileChain = new Zend_Controller_Router_Route_Chain();
$profileChain->chain($language);
$profileChain->chain($profile);
$router->addRoute('profile', $profileChain);
// setup module route (will be chained later) and add to the
// router chained with language
$module = new Zend_Controller_Router_Route_Module(
array(
'module' => 'application',
'controller'=> 'index',
'action' => 'index'
),
Zend_Controller_Front::getInstance()->getDispatcher(),
Zend_Controller_Front::getInstance()->getRequest()
);
$module->isAbstract(true);
$default = new Zend_Controller_Router_Route_Chain();
$default->chain($language);
$default->chain($module);
$router->addRoute('default', $default);
--
Xavier Vidal Piera
Director Tècnic de Citrusparadis.com - Grupo Intercom
Enginyer Tècnic Informàtic de Gestió
Tècnic Especialista Informàtic d'equips
[email protected]
http://web.xaviervidal.net
610.68.41.78