When using the default module "default" appears in the urls e.g.
www.domain/en/default/some/action ?

You could just as well use one route:

$route = new Zend_Controller_Router_Route(
            ':language/:module/:controller/:action/*',
                array(
                    'language'   => 'fr',
                    'module'     => 'default',
                    'controller' => 'index',
                    'action'     => 'index'
                ),
                array(
                    'language' => 'en|fr'
                )
            );

This will still cause "default" to appear in all default module urls? Surly
there's a way to make the module part optional?

2. Why chain the routes, what's the benefit? I'm assuming it's so that the
language route can be used elsewhere, say another module which wouldn't need
to know anything about how the language route is configured, simply know
that it is the language part of the route, e.g. adding extra language
support would only require editing in one place i.e. DRY? 

Gerry


Laurent Melmoux wrote:
> 
>  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
> 
> 
> 

-- 
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF-1-10-4-Chain-route-language-code-tp2282659p2300812.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to