I try to help you based on what I have in my ZF project.
So, in your class Model_DbTable_Order you can defined a method called e.g. getOnePageOfOrderEntries() as follows:
/**
* Return one page of order entries
*
* @param int $page page number
* @return Zend_Paginator Zend_Paginator
*/
public function getOnePageOfOrderEntries($page=1) {
$query = $this->select();
$paginator = new Zend_Paginator(
new Zend_Paginator_Adapter_DbTableSelect($query)
);
$paginator->setItemCountPerPage(100);
$paginator->setCurrentPageNumber($page);
return $paginator;
}
Than in indexAction you can have something like this:
public function indexAction()
{
$this->view->title = "My Orders";
$this->view->headTitle($this->view->title, 'PREPEND');
$orders = new Model_DbTable_Orders();
//$this->view->orders = $orders->fetchAll();
$page = $this->_request->getParam('page');
if (empty($page)) { $page = 1; }
$paginator = $orders->getOnePageOfOrderEntries($page);
$this->view->paginator = $paginator;
}
In your index.phtml view you could have something similar to this:
paginator)): ?>
Name |
Quantity |
|
paginator as $order): ?>
name;?> |
quantity;?> |
|
paginationControl($this->paginator,
'Sliding','partial/my_pagination_control.phtml'); ?>
Where my_pagination_control.phtml is as follows (this is just copy-paste what I have and it is from the ZF Reference quide):
pageCount): ?>
Hope it will be useful.