Somebody
Somebody

Reputation: 9645

Zend Framework - getting page count inside controller or model

$paginator = Zend_Paginator::factory($select);

$paginator->setItemCountPerPage($s['perPage']);
$paginator->setPageRange(15);
$paginator->setCurrentPageNumber((int)$s['page']);

return $paginator;

How to get overall page count from paginator?

Because i want to set 404 header if requested page is > than overall.

Thanks ;)

Upvotes: 2

Views: 2762

Answers (2)

Vika
Vika

Reputation: 3285

You can access overall number of pages with

$paginator->getPages()->pageCount

But basically it just returns the $select->count() value (so piddl0r's guess was correct).

Upvotes: 7

piddl0r
piddl0r

Reputation: 2449

I don't know how it was generated but wouldn't counting the select do the trick?

count($select);

If the the data is coming from database Zend_Paginator_Adapter_DbSelect as an adapter for the paginator is helpful.

Upvotes: 0

Related Questions