Pagination Component

Soon there’ll be more doc in here, for now you can read stuff at my blog

PLEASE NOTE that this component MAY NOT WORK AS EXPECTED with ZF 1.5 and / or 1.0.4. It has not been tested, and due to emerging alternative paginating solutions for the Zend Framework, I may consider discontinuing this component developement (although the decision as not yet been taken, and a port to 1.5 is in progress).

Theory of operation

Basically, the pagination component wraps up around a Zend_Db_Table object overloading !fetchAll to add the offset and count arguments. !fetchAll then returns a Riskle_Db_Table_Rowset_Paginate object which can be used in conjunction with the Riskle_View_Helper_Paginate class to display navigation informations.

Requirements

You will need some components from the Riskle namespace in order to be able to use this pagination component. Luckily, every needed file is included into the distribution archive. For information, the archive tree looks like this:

.
|-- LICENSE
`-- library
    `-- Riskle
        |-- Db
        |   |-- Table
        |   |   |-- Abstract.php
        |   |   |-- Exception.php
        |   |   |-- Paginate
        |   |   |   `-- Exception.php
        |   |   |-- Paginate.php
        |   |   `-- Rowset
        |   |       `-- Paginate.php
        |   `-- Table.php
        |-- Pattern
        |   |-- Proxy
        |   |   `-- Exception.php
        |   `-- Proxy.php
        `-- View
            `-- Helper
                `-- Paginate.php
See also:

Usage

In your bootstrap, you need to register the riskle view helper namespace:


$view = new Zend_View;
$view->setHelperPath('Riskle/View/Helper', 'Riskle_View_Helper'); 
Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer')->view = $view;

In the controller:


 require_once 'models/Table.php';
 $table = new Riskle_Db_Table_Paginate(new Table, $page); // Table is a class extending Riskle_Db_Table
 $this->view->assign('rowset', $table->fetchAll($where)); // !fetchAll's signature is unmodified

In the view:


 <?php $this->paginate($this->rowset); // initializes the helper ?>

 <div id="navigation"><?php
 echo $this->paginate()->previous(); // displays a "previous link" if available
 echo $this->paginate()->navigation(); // displays the list of pages
 echo $this->paginate()->next(); // displays a "next link" if available
 ?></div>

Download

You can always find the latest version of the paginate component on the files area of this space or on the subversion repository (be sure to checkout all required components if using svn).

Pages: 1