我正在使用Zend Framework和URL视图助手来创建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'));

这样,一开始,我有一些像这样的URL

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

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

我该如何解决?

有帮助吗?

解决方案

打电话时需要重置参数 url 帮手。

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

第二个参数是使用路由的名称。收下 null 如果要使用当前路线。
第三个参数告诉是否要重置参数。它是 false 默认。所以,只需将其设置为 true 摆脱现有参数。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top