2

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.

Gaurav Sharma
  • 2,830
  • 1
  • 37
  • 54
  • 1
    You could pass the username to the view and add it to the url's parameters: `$this->url(array('module' => 'client', 'controller' => 'feedback', 'action' => 'new', 'username' => $username), null, true)` or you just set the page-parameter to `null` and omit the final argument when calling the URL-ViewHelper. I think the former is the cleaner way... – dbrumann Oct 03 '12 at 07:30
  • cool, that worked (former approach).. thanks. :) Can you please post that reply as an answer to this question.? – Gaurav Sharma Oct 03 '12 at 07:50

1 Answers1

5

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)
dbrumann
  • 16,803
  • 2
  • 42
  • 58