1

我正在使用 Zend Framework 和 URL View Helper 创建 URL

我的导航中有一些这样的行:

$this->url(array('controller' => 'index', 'action' => 'index'))
$this->url(array('controller' => 'who', 'action' => 'view', 'id' => $row->who_id));
$this->url(array('controller' => 'projects', 'action' => 'view', 'id' => $row->mai_id));
$this->url(array('controller' => 'content', 'action' => 'view', 'type' => 'theater', 'id' => $row->the_id));
$this->url(array('controller' => 'shows', 'action' => 'view'));

这样,起初,我有一些这样的网址

http://ccgss.local/information/location
http://ccgss.local/who/view/id/1

但是当我访问另一个带有更多参数的链接时,http://ccgss.local/content/view/id/1/type/theater 它会与仍然存在的参数混淆:http://ccgss.local/who/view/id/1/type/theater

我的意思是,当我访问另一个页面时,参数不会清理。

我该如何解决?

4

1 回答 1

5

url调用helper时需要重新设置参数。

$this->url(array('controller' => 'index', 'action' => 'index'), null, true);

第二个参数是要使用的路由的名称。null如果您想使用当前路线,请保留它。
第三个参数告诉是否要重置参数。false默认情况下。因此,只需将其设置true为摆脱现有参数。

于 2010-10-20T17:59:02.197 回答