2

我正在尝试使用 zend 框架(v 1.11)开发应用程序。我对这个框架完全陌生。

我有一个这样的网址。

http://xyz.local/client/feedback/index/username/abc/page/2

上面的链接指向client模块,feedback控制器的index动作。

每个请求都需要url 参数username和有效值。

在此页面上,我已对所有反馈进行了分页。我的问题是,当我从index操作导航到相同或不同控制器中的其他操作时,参数名称/page/2仍保留在 url 中。

假设如果我导航到new同一个控制器的操作,那么新的 URL 看起来像这样

http://xyz.local/client/feedback/new/username/newClient/page/2

而它应该是这样的

http://xyz.local/client/feedback/new/username/newClient

使用$this->url(array('module' => 'client', 'controller' => 'feedback', 'action' => 'new'), null, true)重置所有参数,包括我不想要的用户名。

Zend 的标准做法是什么。

4

1 回答 1

5

您可以将用户名传递给视图并将其添加到 URL-ViewHelper 中的 url 参数中:

$this->url(array('module' => 'client', 'controller' => 'feedback', 'action' => 'new', 'username' => $username), null, true)
于 2012-10-03T08:28:18.430 回答