Answer the question
In order to leave comments, you need to log in
How to make a pager in Zend Framework 1?
Hello, I'm trying to understand this framework, I need the first version. I am making a guest book for this series of articles ruseller.com/lessons.php?rub_id=37&id=989 with my minor edits (I display everything on the index page). It is necessary to implement a pager, I found something here framework.zend.com/manual/1.12/en/zend.paginator.u... but I still don't understand how to attach it to my case... It seems that I I did everything wrong from the very beginning. Please help.
Answer the question
In order to leave comments, you need to log in
The view now needs to pass a Zend_Paginator object (an array of paginated movies). I will give the simplest option, using Zend_Paginator_Adapter_Array. Once you're comfortable with it, you can rewrite it with an adapter that uses a database:
public function indexAction()
{
$movies = new Application_Model_DbTable_Movies();
$paginator = Zend_Paginator::factory($movies->fetchAll());
$paginator->setItemCountPerPage(15);
$page = $this->_getParam('page', 1);
$paginator->setCurrentPageNumber($page);
$this->view->movies = $paginator->getCurrentItems();
$this->view->paginator = $paginator;
}
<table>
<tr>
<th>Название</th>
<th>Режиссёр</th>
<th> </th>
</tr>
<?php echo $this->partialLoop('partials/movie.phtml', $this->movies); ?>
</table>
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination_control.phtml'); ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question