用于自定义模块的Zend Translate Routing

时间:2013-10-15 09:00:36

标签: php zend-framework zend-route zend-translate zend-router

如何在自定义模块(在我的情况下为admin模块)中为Zend Framework设置默认语言的路由。

我有以下代码:

$langRoute = new Zend_Controller_Router_Route(
   ':lang/admin',
   array(
      'lang' => 'ro',
   )
);

我想要获得的是url,如下所示:

www.example.com/ro/admin/pages/add/62
www.example.com/ro/admin/pages/index/by/date_modified/order/asc

1 个答案:

答案 0 :(得分:0)

尝试此操作:

protected function _initRoutes() {
    $langRoute = Zend_Controller_Front::getInstance ()->getRouter ();
    $langRoute->removeDefaultRoutes ();
    $route = new Zend_Controller_Router_Route(
       ':lang/:module/:controller/:action/*',
        array (
            'lang' => 'ro',
            'module' => 'admin',
            'controller' => 'index',
            'action' => 'index'
        )
    );
    $langRoute->addRoute ( 'langrouter', $route );
}