Class Pinoco_Pagination
Pagination object designed for PHPTAL. This object is independent from RDBMS. You can use it with any data source.
$pagination = new Pinoco_Pagination( // How many elements? function($pagination) { return $pagination->db->prepare( "SELECT count(id) as c FROM ..." )->query()->fetchOne()->c; }, // What to be shown? function($pagination, $offset, $limit) { return $pagination->db->prepare( "SELECT * FROM ... LIMIT $offset, $limit" )->query()->fetchAll(); }, // How the page number is formatted in navigation? function($pagination, $page) { return 'list' . ($page > 1 ? '?page=' . $page : ''); }, array( 'elementsPerPage' => 20, 'db' => $db, // you can pass any custom property to pagination. ) ); $pagination->page = 1; if (!$pagination->isValidPage) { $this->notfound(); }
PHPTAL example
<tal:block tal:repeat="element pagination/data"> ${element/prop} </tal:block> <div class="pagination" tal:define="prev pagination/prev; pages pagination/pages; next pagination/next"> <!--! prev button --> <a href="" tal:condition="prev/enabled" tal:attributes="href url:${prev/href}">PREV</a> <span class="disabled" tal:condition="not:prev/enabled">PREV</span> <!--! page link buttons --> <tal:block tal:repeat="page pages"> <tal:block tal:condition="not:page/padding"> <a href="" tal:condition="not:page/current" tal:attributes="href url:${page/href}" tal:content="page/number">1</a> <span class="current" tal:condition="page/current" tal:content="page/number">1</span> </tal:block> <span tal:condition="page/padding">...</span> </tal:block> <!--! next button --> <a href="" tal:condition="next/enabled" tal:attributes="href url:${next/href}">NEXT</a> <span class="disabled" tal:condition="not:next/enabled">NEXT</span> </div>
- Pinoco_Vars implements IteratorAggregate, ArrayAccess, Countable, Pinoco_ArrayConvertible
- Pinoco_DynamicVars
- Pinoco_Pagination
Package: Pinoco
Copyright: Copyright 2010-2012, Hisateru Tanaka <tanakahisateru@gmail.com>
License: License (http://www.opensource.org/licenses/mit-license.php)
Author: Hisateru Tanaka <tanakahisateru@gmail.com>
Located at Pinoco/Pagination.php
Copyright: Copyright 2010-2012, Hisateru Tanaka <tanakahisateru@gmail.com>
License: License (http://www.opensource.org/licenses/mit-license.php)
Author: Hisateru Tanaka <tanakahisateru@gmail.com>
Located at Pinoco/Pagination.php
public
|
#
__construct( callable $totalCountCallable, callable $dataFetchCallable, callable $urlFormatCallable, array $options = array() )
Creates pagination object from user codes. |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
integer
|
|
public
mixed
|
|
public
|
|
public
integer
|
|
public
|
|
public
|
|
public
|
get(),
getIterator(),
has(),
keys(),
set()
|
__call(),
__get(),
__isset(),
__set(),
__toString(),
__unset(),
count(),
fromArray(),
import(),
markAsDirty(),
offsetExists(),
offsetGet(),
offsetSet(),
offsetUnset(),
registerAsDynamic(),
registerAsLazy(),
registerAsMethod(),
remove(),
rget(),
setDefault(),
setLoose(),
toArray(),
toArrayRecurse(),
values(),
wrap()
|
public
integer
|
$page |
#
The page number that starts with 1. (not 0!) |
public
integer
|
$elementsPerPage |
#
Amount of data shown in single page. |
public
integer
|
$pagesAfterFirst |
#
How many buttons after the first page. (-1: hides first page) |
public
integer
|
$pagesAroundCurrent |
#
How many buttons around current page. (-1: expand all pages) |
public
integer
|
$pagesBeforeLast |
#
How many buttons before the last page. (-1: hides last page) |
public read-only
integer
|
$totalCount |
#
Total number of elements. |
public read-only
integer
|
$totalPages |
#
Total number of pages. |
public read-only
mixed
|
$data |
#
Elements in paginated range. |
public read-only
|
$pages |
#
Navigation information of each page buttons. |
public read-only
|
$prev |
#
Navigation information of the prev button. |
public read-only
|
$next |
#
Navigation information of the prev button. |