Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-22-2008, 06:05 PM
Junior Member
 
Join Date: Dec 2007
Posts: 15
Default Zend_Paginator using Select Adapter

Hi,

I'm using Paginator like this:
$select = $this->db->select()
->from(array('mh' => 'merlin_hotel'))
->join(array('mt' => 'merlin_trip') ,'mt.id = mh.trip_id', array() );
$select->where('mh.region = ?',$region);

$paginator = Zend_Paginator::factory($select);
$paginator->setCurrentPageNumber((int)$this->getRequest()->getParam('page'));
$this->view->paginator = $paginator;
$this->render("results")

but the links that are being rendered later in the pagination_control.phtml do not contain the query parameters that were set before.
To achieve that, I have to pass the params from controller to the viewscript and then from the view script to pagination view script and again then merge with 'page' param which is pointless and not making it easier at all.
Any hints on that?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-04-2008, 03:05 PM
Junior Member
 
Join Date: Apr 2008
Posts: 5
Send a message via ICQ to tomas.fejfar
Default

You have to setup a query containing the page number. like:
:controller/:action/age

And paginator will then use this route in the url helper method to generate the HREF
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-10-2008, 07:06 PM
Junior Member
 
Join Date: Sep 2008
Posts: 2
Default

I am having the same problem... it's not the page and the count that is getting me confused... it's how I can pass URL parameters into the paginator so they are passed into the HREF.

so for example, my URL looks like this: /data/show/1/50/search?field1=5&field2=20

where "1" is my page, "50" is the count of entries to display per page... and field1 and field 2 are my URL parameters I would like to carry with me..

unfortunately, the HREF for the next and previous button only have this:

/data/show/1/50/search

..

how would I fix this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-20-2008, 04:03 PM
Junior Member
 
Join Date: Sep 2007
Posts: 10
Default

I would also like to know the answer to this.
Surely somebody knows?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-20-2008, 04:54 PM
Junior Member
 
Join Date: Sep 2007
Posts: 10
Default

Infact, what I really want is to keep a url structure of /controller/action/param1/value1/param2/value2/page/1, but I can't find any examples online to help me.
Would you use a GET or POST action in Zend_Form?

I'd love to see a tutorial of using Zend_Form, Zend_Paginator and Zend_Db together...a search form would be a perfect example.

For now I've modified the pagination control view script like this:
PHP Code:
<!-- 
See http://developer.yahoo.com/ypatterns/pattern.php?pattern=itempagination
-->
<?php
$queryString 
= ($_SERVER['QUERY_STRING'] != '') ? '?' $_SERVER['QUERY_STRING'] : '';
?>
<?php 
if ($this->pageCount): ?> 
<div class="paginationControl">
Showing 
<?= $this->firstItemNumber?> - <?= $this->lastItemNumber?> 
of <?= $this->totalItemCount?>

<!-- First page link -->
<?php if (isset($this->previous)): ?>
  <a href="<?= $this->url(array('page' => $this->first)) . $queryString?>">First</a> | 
<?php else: ?>
  <span class="disabled">First</span> |
<?php endif; ?> 

<!-- Previous page link --> 
<?php if (isset($this->previous)): ?> 
  <a href="<?= $this->url(array('page' => $this->previous)) . $queryString?>">&lt; Previous</a> | 
<?php else: ?> 
  <span class="disabled">&lt; Previous</span> | 
<?php endif; ?> 

<!-- Next page link --> 
<?php if (isset($this->next)): ?> 
  <a href="<?= $this->url(array('page' => $this->next)) . $queryString?>">Next &gt;</a> |
<?php else: ?> 
  <span class="disabled">Next &gt;</span> |
<?php endif; ?>

<!-- Last page link -->
<?php if (isset($this->next)): ?>
  <a href="<?= $this->url(array('page' => $this->last)) . $queryString?>">Last</a>
<?php else: ?>
  <span class="disabled">Last</span>
<?php endif; ?> 

</div> 
<?php endif; ?>
All I'm doing is getting the query string if it exists:
PHP Code:
$queryString = ($_SERVER['QUERY_STRING'] != '') ? '?' $_SERVER['QUERY_STRING'] : ''
Then appending it to the url view helper:
PHP Code:
<a href="<?= $this->url(array('page' => $this->last)) . $queryString?>">Last</a>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:22 AM.