onassar / PHP-Pagination

Simple and lightweight PHP pagination class that works with Twitter Bootstrap. Manages pagination variables through instantiable class, and markup rendering through view-like include file.

Home Page:http://web.onassar.com/blog/2012/06/09/github-project-php-pagination/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP Pagination

PHP-Pagination contains an instantiable class, along with a view which renders the pagination markup.

The purpose of this library is to provide a simple API to render pagination markup, without having to worry about including common files and set too many settings. With this class, you simply pass in your parameters and make a call to the instance's parse method.

Pagination Instantiation and Rendering

// source inclusion
require_once APP . '/vendors/PHP-Pagination/Pagination.class.php';

// set the page number (based on a URL param; cast as an int; ensure min page number)
$page = $_GET['page'] ?? 1;
$page = (int) $page;
$page = min($page, 1);

// instantiate; set current page; set number of records per page; number of records in total
$pagination = new Pagination();
$pagination->setCurrent($page);
$pagination->setRPP(24);
$pagination->setTotal(200);

// grab rendered pagination markup
$markup = $pagination->parse();

About

Simple and lightweight PHP pagination class that works with Twitter Bootstrap. Manages pagination variables through instantiable class, and markup rendering through view-like include file.

http://web.onassar.com/blog/2012/06/09/github-project-php-pagination/

License:MIT License


Languages

Language:PHP 71.8%Language:CSS 28.2%