2017 © Pedro Peláez
 

library ypaginator

A lightweight PHP paginator without a database dependency, for generating pagination controls in the style of Yandex

image

dotzero/ypaginator

A lightweight PHP paginator without a database dependency, for generating pagination controls in the style of Yandex

  • Wednesday, October 11, 2017
  • by dotzero
  • Repository
  • 2 Watchers
  • 2 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

PHP YPaginator

Build Status Latest Stable Version License, (*1)

A lightweight PHP paginator without a database dependency, for generating pagination controls in the style of Yandex., (*2)

Features

  • The first and last page links are shown
  • The current and neighbours page links are shown
  • Rest of links are replaced by ellipses

How it looks like:

<< previous | next >>
|1| ... |5||6||7| ... |100|

Usage

$total = 100; // Total items
$perpage = 10; // Items per page
$current = 5; // Current page
$neighbours = 2; // Neighbours links beside current page

$y = new \dotzero\YPaginator($total, $perpage, $current);

$paginator = $y
    ->setNeighbours($neighbours)
    ->setUrlMask('#num#')
    ->setUrlTemplate('/foo/page/#num#')
    ->getPaginator();

print_r($paginator);

Output looks like:, (*3)

[
    "prev" => ["name" => 4,"url" => "/foo/page/4","current" => false], // Previous
    "pages" => [
        ["name" => 1,"url" => "/foo/page/1","current" => false], // First
        ["name" => "...","url" => "/foo/page/2","current" => false],
        ["name" => 3,"url" => "/foo/page/3","current" => false], // Neighbour
        ["name" => 4,"url" => "/foo/page/4","current" => false], // Neighbour
        ["name" => 5,"url" => "/foo/page/5","current" => true],  // Current
        ["name" => 6,"url" => "/foo/page/6","current" => false], // Neighbour
        ["name" => 7,"url" => "/foo/page/7","current" => false], // Neighbour
        ["name" => "...","url" => "/foo/page/8","current" => false],
        ["name" => 10,"url" => "/foo/page/10","current" => false] // Last
    ],
    "next" => ["name" => 6,"url" => "/foo/page/6","current" => false] // Next
];

Install

Via composer:

$ composer require dotzero/ypaginator

Without composer

Clone the project using:, (*4)

$ git clone https://github.com/dotzero/ypaginator-php

and include the source files with:, (*5)

require_once("ypaginator-php/src/YPaginator.php");

Test

First install the dependencies, and after you can run:, (*6)

$ vendor/bin/phpunit

License

Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php, (*7)

The Versions

11/10 2017

dev-master

9999999-dev

A lightweight PHP paginator without a database dependency, for generating pagination controls in the style of Yandex

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar dotzero

pagination paginator pager

13/04 2016

0.7

0.7.0.0

A lightweight PHP paginator without a database dependency, for generating pagination controls in the style of Yandex

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Avatar dotzero

pagination paginator pager