2017 © Pedro Peláez
 

extension li3_pagination

Pagination helper for the Lithium PHP framework

image

thedisco/li3_pagination

Pagination helper for the Lithium PHP framework

  • Wednesday, June 27, 2012
  • by the_disco
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

li3_paginate

li3_pagination was designed to facilitate generating of pagination for Lithium Framework projects. So far helper can generate a pagination from a record set for the current context or from an arbitrary record count. You cannot provide custom arguments for the route generation. Helper cannot extract the query from the provided record set either. It is planed to extend the behavior of the helper to support custom route parameters., (*1)

Installation

Clone this repo into the libraries folder of your project., (*2)

cd /path/to/app/libraries
git clone https://github.com/theDisco/li3_pagination.git

Before you can use this helper, you need to tell lithium to load this extension. The best way to do it is to add it as a library in the bootstrap process:, (*3)

``` php false)); // ... ``` You also need to inform Lithium how to map the page param from the request. You can use the example route below or change it according to your needs: ``` php request->page ?: 1; $options = compact('limit', 'page'); $binding = Posts::find('all', $options); return compact('binding', 'options'); } // ... ?>, (*4)


In your view you just need to add following code: ``` php <?php echo $this->pagination->create($binding, $options); echo $this->pagination->first(); echo $this->pagination->previous(); echo $this->pagination->pages(); echo $this->pagination->next(); echo $this->pagination->last(); echo $this->pagination->end(); ?>

You can also use the compound methods for creating the first, previous, next and last page., (*5)

``` php pagination->create($binding, $options); echo $this->pagination->pre(); echo $this->pagination->pages(); echo $this->pagination->post(); echo $this->pagination->end(); ?>, (*6)


By default li3_pagination renders the pages even if only one page is present in pagination. If you want to hide the pagination you can use following syntax: ``` php <?php if ($this->pagination->create($binding, $options + array('start' => false))->count() > 1) { echo $this->pagination->start(); echo $this->pagination->pre(); echo $this->pagination->pages(); echo $this->pagination->post(); echo $this->pagination->end(); } ?>

li3_pagination does not have a constructor and is really similar in the usage to the form helper provided with the Lithium Framework. Create method takes a binding as the first argument and an array of options as the second argument. You can define any class as the binding as long as it implements the method model(). The value returned by model() method has to be a string or an object you can use to invoke the method count(). Basically the \lithium\data\collection\RecordSet is the perfect candidate as the first argument. Second argument is an array of options., (*7)

If you have defined any conditions for your model, li3_pagination won't be able to retrieve the correct count. In this case you can provide the records count as the first argument of create() method., (*8)

``` php pagination->create('150', $options); ?>, (*9)


Configuration and Options ------------------------- ``` php $options = array( 'page' => 1, 'limit' => 20, 'start' => true, );

TODO Document the options, (*10)

TODO

  • Document the options and filters supported by this helper.
  • Add support for arbitrary route parameters.
  • Introduce filters for all relevant methods.
  • Complete the code documentation.
  • Refactor the default settings and configuration.
  • Finish tests

The Versions

27/06 2012

dev-master

9999999-dev https://github.com/theDisco/li3_pagination

Pagination helper for the Lithium PHP framework

  Sources   Download

BSD-3-Clause

The Requires

 

pagination lithium