3

在我的引导程序中,我有

$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 

代替

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

有任何想法吗?

4

1 回答 1

2

当然,一种解决方案(使用 Apache)在我看来是这样称呼的:

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

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

于 2012-05-18T17:36:43.190 回答