I have a page that displays a lot of data, including Zend_Paginator.
The page action is /po/fetch?id=someID
.
what i want to do is to pass the "id" parameter to zend paginationControl so the pagination links will be something like /po/fetch?id=someID&page=somePage
. unfortunally i can't find anywhere explanation on how i can pass that parameter to the paginationControl.
my call to paginationControl:
echo $view->paginationControl($paginator, 'Sliding',$control, $params);
where $params = array('id' => someID
and my pagination partial is:
<a href=<?= $url.'&page='.$this->first; ?> id="first"> First </a>
<a href=<?= $url.'&page='.$this->previous; ?> id="previous">< Previous</a>
<?php
foreach($this->pagesInRange as $page) {
?>
<a href="<?= $url.'&page='.$page; ?>">.$page.</a> | ;
<?php
}
?>
<a href=<?= $url.'&page='.$this->next;?> id="next"> Next ></a>
<a href=<?= $url.'&page='.$this->last; ?> id="last"> Last </a>
and I want $url
to be of the specified form.
$this->id
Hey Try this, It will surely work.....
<a href="<?php echo $this->url(array('page' => $page,'id'=>'1')); ?>">
<?php echo $page; ?>
</a>
Here 1
is given as the id you have to pass the id you want.......
Like
<a href="<?php echo $this->url(array('page' => $page,'id'=>$param['id'])); ?>">
<?php echo $page; ?>
</a>
Your example code doesn't show how $url
is populated, but you really should be using the URL ViewHelper.
So, for example - your previous link would become:
<a href=<?php echo $this->url(array('page' => $this->previous)); ?> id="previous">< Previous</a>
This will return a proper URL to the current page with the page
parameter set to $this->previous
. So if the current url is /users/view?foo=bar&page=5
, the above code would output /users/view?foo=bar&page=4
for the previous link. Notice how any query parameters that are already present are preserved.
So, if the id
parameter is already present on the URL showing your paginator, the above code will "just work". However, if you still need to add the id
parameter, you can do so like this:
<a href=<?php echo $this->url(array('page' => $this->previous, 'id' => $this->id)); ?> id="previous">< Previous</a>
To continue from our previous example, this code would output the following url: /users/view?foo=bar&page=4&id={someId}
Here is the reference documentation for the URL ViewHelper:
url($urlOptions, $name, $reset): Creates a URL string based on a named route. $urlOptions should be an associative array of key/value pairs used by the particular route.
One last note - the $reset
(third) parameter of the URL ViewHelper will come in very handy. The default behavior is to preserve any query parameters of the current request but calling $this->url(array(), 'default', true)
with true
for the $reset
parameter will basically remove all parameters except for the ones you specify in $urlOptions
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With