zend-frameworkurl-parametersurlvariables

How do I remove only few url parameters in zend framework


I am trying to develop an application using zend framework (v 1.11). Am totally new to this framework.

I have a URL like this.

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

The above link points to client module, feedback controller's index action.

url parameter username along with a valid value is necessary for every request.

On this page I have paginated all the feedbacks. My probem is that when I navigate away from the index action to some other action in same or different controller the parameter name /page/2 still remains in the url.

For suppose if I navigate to new action of same controller then the new URL appears like this

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

whereas it should have been like this

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

Using the $this->url(array('module' => 'client', 'controller' => 'feedback', 'action' => 'new'), null, true) resets all the parameters including the username, which I do not want.

What's the standard Zend's way of doing this.


Solution

  • You can pass the username to the view and add it to the url's parameters in the URL-ViewHelper:

    $this->url(array('module' => 'client', 'controller' => 'feedback', 'action' => 'new', 'username' => $username), null, true)