Andrew
Andrew

Reputation: 238647

Zend Framework URL view helper is not displaying full url?

I have a url that looks like this:

/controller/action?query=foobar

In my paginator view script, I am calling the URL view helper to add the page number to the url:

<a href="<?php echo $this->url(array('page' => $this->next), null, false); ?>">

Passing false should make it so that the URL is not reset, but the URL being generated does not include the original query parameter:

/controller/action/page/2

...and it should be:

/controller/action/page/2?query=foobar

What am I doing wrong?

Upvotes: 1

Views: 845

Answers (2)

Jirka Helmich
Jirka Helmich

Reputation: 106

You'd better use the following format of the URL:

/controller/action/query/foobar

That should be compatible with the URL helper non-reset functionality and your code should work.

Upvotes: 0

brady.vitrano
brady.vitrano

Reputation: 2256

You will have to add the query string to the end of the URL that is created by the Helper. The helper's job is to create links based on defined routes. It will not maintain query strings because no route in Zend has a query string.

<a href="<?php echo $this->url(array('page' => $this->next), null, false); ?>?<?php echo $_SERVER['QUERY_STRING'];?>">

Upvotes: 3

Related Questions