Friends,
I want to create pagination in Zend Framework. I'm new to ZF.
index.phtml is given below
<table>
<tr>
<th>Name</th>
<th>Quantity</th>
<th> </th>
</tr>
<?php foreach($this->orders as $order) : ?>
<tr>
<td><?php echo $this->escape($order->name);?></td>
<td><?php echo $this->escape($order->quantity);?></td>
<td>
<a href="<?php echo $this->url(array('controller'=>'index','action'=>'edit', 'id'=>$order->id));?>">Edit</a>
<a href="<?php echo $this->url(array('controller'=>'index', 'action'=>'delete', 'id'=>$order->id));?>">Delete</a>
</td>
</tr>
<?php endforeach; ?>
</table>
<p><a href="<?php echo $this->url(array('controller'=>'index','action'=>'add'));?>">Add new album</a></p>
My index controller is below
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
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();
}
}
Try this http://zendgeek.blogspot.com/2009/07/zend-pagination-example.html
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:
Than in indexAction you can have something like this:
In your index.phtml view you could have something similar to this:
Where my_pagination_control.phtml is as follows (this is just copy-paste what I have and it is from the ZF Reference quide):
Hope it will be useful.