Zend Framework:路由汇编和GET参数

时间:2012-05-17 18:13:12

标签: zend-framework routes

在我的Bootstrap中我有

$route = new Zend_Controller_Router_Route(
    ':language/:country/:controller/:action/*', 
    array(
        'language' => 'en',
        'country' => 'us',
        'controller' => 'bicycle',
        'action' => 'index'
    ),
    array(
        'language' => '[a-z][a-z]',
        'country' => '[a-z][a-z]'
    )
);

在我看来,我有

echo $this->url(array('page'=>2));
//actually this translated to $route->assemble(array('page' => 2), null, false);

问题是,当我有一些GET参数时:它们不会在链接的构建中被考虑,这就是我真正想要的。

实施例: 我访问URL(在浏览器中)

http://localhost/myproject/en/us/controller/action/?get1=gval1&get2=gval2&get3=gval3 

,汇编的网址为

http://localhost/myproject/en/us/controller/action/page/2 

INSTEAD

http://localhost/myproject/en/us/controller/action/page/2/get1/gval1/get2/gval2/get3/gval3/ 

或(我更喜欢下一个)

http://localhost/myproject/en/us/controller/action/page/2/?get1=gval1&get2=gval2&get3=gval3

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

当然,一个解决方案(使用Apache)将在我的视图中调用它:

$this->url(array(page=>2)) . ($_SERVER['QUERY_STRING']?$_SERVER['QUERY_STRING']:"")

但您无法确定这将始终包含在$ _SERVER变量中。