Zend_Paginator Without Adapter Data
If you simply want to take advantage of Zend_Paginators page generation function without feeding it actual data, how do you do it? Simple, implement Zend_Paginator_Adapter_Interface in your custom class and override three functions like below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<?php class Dotmanila_Paginator_Adapter_Null implements Zend_Paginator_Adapter_Interface { private $_count = 0; public function __construct(array $data) { if(isset($data['count']) AND $data['count'] > 0) { $this->_count = $data['count']; } } public function getItems($offset, $itemCountPerPage) { return array(); } public function count() { return $this->_count; } } ?> |
Then you can use it as you would the paginator class – the only parameter to the constructor is the total number of items to base the paging against.
1 2 |
$dpa = new Dotmanila_Paginator_Adapter_Null(array('count' => $count)); $pages = $dpa->getPages(); |