views:

477

answers:

3

Hi,

I am using .ini file to add routes in my application.

resources.router.routes.username.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.username.route = ":username.example.com"
resources.router.routes.username.defaults.module = "userinfo"
resources.router.routes.username.chains.index.type = "Zend_Controller_Router_Route"
resources.router.routes.username.chains.index.route = ":language/:controller/:action/*"
resources.router.routes.username.chains.index.defaults.controller = "index"
resources.router.routes.username.chains.index.defaults.action = "index"

1) http://john.example.com/fr/controller/action
2) http://john.example.com/fr/controller/action/id/10

#1 url it's work. Request parameter here

Request Parameters:
array (
  'language' => 'fr',
  'controller' => 'controller',
  'action' => 'action',
  'username' => 'john',
  'module' => 'userinfo',
)

#2 url it's not work. Request parameter here

Request Parameters:
array (
  'controller' => 'fr',
  'action' => 'controller',
  'module' => 'default',
)

Can anyone suggest a solution for this.

A: 

did you set a default language for the route? by saying it doesn't work could you provide more details? I ran into some similar problem with Zend_navigation not taking in the language param and always switch to the default lang that i defined.

Eventually i have to hack it by manually setting default language in the routshutdown in a custom plugin please see my post if it helps

http://stackoverflow.com/questions/1564931/zend-framework-zendtranslate-and-routing-related-issue

Dan
A: 
resources.router.routes.username.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.username.route = ":username.example.com"
resources.router.routes.username.defaults.module = "userinfo"
resources.router.routes.username.chains.index.type = "Zend_Controller_Router_Route"
resources.router.routes.username.chains.index.route = ":language/:controller/:action/*"
resources.router.routes.username.chains.index.defaults.controller = "index"
resources.router.routes.username.chains.index.defaults.action = "index"
resources.router.routes.username.chains.index.defaults.language = "en"

I add to default language parameter in route. But this url not work

http://john.example.com/fr/controller/action/id/10
Request Parameters:
array (
  'controller' => 'fr',
  'action' => 'controller',
  'module' => 'default',
)
scopus
A: 

Looks like the route has been reset to default. I run into that before

create a plugin and register to the front controller. Define dispatchLoopStartup() in there try set the language parameter or module name using

$router = $fc->getRouter();
$router->setGlobalParam('lang','somelanguage');
$router->setGlobalParam('module','somemodule');

see if you can bring back the correct route.

Dan