How can i get the page details in controller's action? I have used the album's pagination.
$iteratorAdapter = new \Zend\Paginator\Adapter\Iterator($this->getAlbumTable()->fetchAll());
$paginator = new \Zend\Paginator\Paginator($iteratorAdapter);
$paginator->setCurrentPageNumber($page);
$paginator->setItemCountPerPage(2);
return new ViewModel(array(
'paginator' => $paginator
));
I had tried to get by using the method getPages().
$iteratorAdapter = new \Zend\Paginator\Adapter\Iterator($this->getAlbumTable()->fetchAll());
$paginator = new \Zend\Paginator\Paginator($iteratorAdapter);
$paginator->setCurrentPageNumber($page);
$paginator->setItemCountPerPage(2);
$pagingInfo = $paginator->getPages();
return new ViewModel(array(
'paginator' => $paginator,
'pagingInfo' => $pagingInfo,
));
In this case, i have 8 records in table. Perpage is 2. so, i have 4 pages. After using getPages() method, 3rd & 4th pages has no records. But pagination is exist.
What's wrong? Is there any other method to get total no of records, current page number and current page records count in controller? Please suggest me.