0

ZF v.1.12 でいくつかのカスタム ルートを作成する必要があります。

protected function _initRouter() {
    $this->bootstrap('FrontController');
    $this->bootstrap('locale');

    $front = Zend_Controller_Front::getInstance ();
    $router = $front->getRouter ();

    $router->addRoute ( 'fastproduct', new Zend_Controller_Router_Route_Regex ( '(.+)\.html', array ('module' => 'default', 'controller' => 'products', 'action' => 'get' ), array (1 => 'q' ), '%s.html' ) );
    $router->addRoute ( 'products', new Zend_Controller_Router_Route_Regex ( 'products/(.+)\.html', array ('module' => 'default', 'controller' => 'products', 'action' => 'get' ), array (1 => 'q' ), 'products/%s.html' ) );
    $router->addRoute ( 'categories', new Zend_Controller_Router_Route_Regex ( 'categories/(.+)\.html', array ('module' => 'default', 'controller' => 'categories', 'action' => 'list' ), array (1 => 'q' ), 'categories/%s.html' ) );
    $router->addRoute ( 'cms', new Zend_Controller_Router_Route_Regex ( 'cms/(.+)\.html', array ('module' => 'default', 'controller' => 'cms', 'action' => 'page' ), array (1 => 'url' ), 'cms/%s.html' ) );
    $router->addRoute ( 'wiki', new Zend_Controller_Router_Route_Regex ( 'wiki/(.+)\.html', array ('module' => 'default', 'controller' => 'wiki', 'action' => 'help' ), array (1 => 'uri' ), 'wiki/%s.html' ) );
    $router->addRoute ( 'tlds', new Zend_Controller_Router_Route_Regex ( 'tlds/(.+)\.html', array ('module' => 'default', 'controller' => 'tlds', 'action' => 'index' ), array (1 => 'uri' ), 'tlds/%s.html' ) );

    return $router;
}

これらのリンクを呼び出すと、同様に機能します。

# http://www.mydomain.com/productname.html  
# http://www.mydomain.com/products/productname.html
# http://www.mydomain.com/categories/hosting.html
# http://www.mydomain.com/cms/mypage.html
# http://www.mydomain.com/wiki/myhelp.html
# http://www.mydomain.com/tlds/com.html
# http://www.mydomain.com/admin/

しかし、これらすべての次のリンクに言語を追加するにはどうすればよいですか?

# http://www.mydomain.com/it/productname.html   
# http://www.mydomain.com/it/products/productname.html
# http://www.mydomain.com/it/categories/hosting.html
# http://www.mydomain.com/it/cms/mypage.html
# http://www.mydomain.com/it/wiki/myhelp.html
# http://www.mydomain.com/it/tlds/com.html
# http://www.mydomain.com/it/admin

親切に助けてくれてありがとう。

4

1 に答える 1