Skip to content

Rundiz/pagination

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

Pagination Component

PHP Pagination.
The highly customizable PHP pagination class.

Latest Stable Version License Total Downloads

Example:

// You don't need to include or require file if you install via Composer.
require_once '../Rundiz/Pagination/Pagination.php';

$total_records = 1000;
$start = (isset($_GET['start']) ? intval($_GET['start']) : 0);
if ($start < 0) {
    $start = 0;
}
$limit = 10;

$Pagination = new \Rundiz\Pagination\Pagination();
// Set options to the pagination class.
$Pagination->base_url = 'http://localhost/your-project/page.php?start=%PAGENUMBER%';// *This property must be set.
$Pagination->total_records = $total_records;// *This property must be set.
$Pagination->page_number_value = $start;// *This property must be set.
echo $Pagination->createLinks();

More example is in tests folder.

Pagination parts description

Pagination

  • "before unavailable" items number can be set via "unavailable_before" property. Example: $Pagination->unavailable_before = 1;
  • "unavailable" text can be set via "unavailable_text" property. Example: $Pagination->unavailable_text = '..';
  • "adjacent pages" can be set the number via "number_adjacent_pages" property. Example: $Pagination->number_adjacent_pages = 3;
  • "after unavailable" items number can be set via "unavailable_after" property. Example: $Pagination->unavailable_after = 2;