bootpress / pagination
Creates customizable pagination and pager links. Limits and offsets arrays and database queries. Built-in styles for Bootstrap, Zurb Foundation, Semantic UI, Materialize, and UIkit.
Installs: 1 201
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=5.4
- bootpress/page: ^1.0
Requires (Dev)
- bootpress/htmlunit: ^1.0
- friendsofphp/php-cs-fixer: ^1.0
- squizlabs/php_codesniffer: ^2.5
This package is not auto-updated.
Last update: 2024-11-23 20:09:59 UTC
README
Creates customizable pagination and pager links. Limits and offsets arrays and database queries. Built-in styles for Bootstrap, Zurb Foundation, Semantic UI, Materialize, and UIkit.
Installation
Add the following to your composer.json
file.
{ "require ": { "bootpress/pagination": "^1.0" } }
Example Usage
<?php use BootPress\Pagination\Component as Paginator; $pagination = new Paginator; // Paginate an array $records = range(1, 100); if (!$pagination->set('page', 10, 'http://example.com')) { $pagination->total(count($records)); } $display = array_slice($records, $pagination->offset, $pagination->length); echo implode(',', $display); // 1,2,3,4,5,6,7,8,9,10 // Generate pagination links echo $pagination->links(); /* <ul class="pagination"> <li class="active"><span>1</span></li> <li><a href="http://example.com?page=2of10">2</a></li> <li><a href="http://example.com?page=3of10">3</a></li> <li><a href="http://example.com?page=4of10">4</a></li> <li><a href="http://example.com?page=5of10">5</a></li> <li><a href="http://example.com?page=6of10">6</a></li> <li><a href="http://example.com?page=7of10">7</a></li> <li class="disabled"><span>…</span></li> <li><a href="http://example.com?page=10of10">10</a></li> <li><a href="http://example.com?page=2of10">»</a></li> </ul> */ // And a pager for good measure echo $pagination->pager(); /* <ul class="pager"> <li class="next"><a href="http://example.com?page=2of10">Next »</a></li> </ul> */
License
The MIT License (MIT). Please see License File for more information.