2017 © Pedro Peláez
 

library pop-paginator

Pop Paginator Component for Pop PHP Framework

image

popphp/pop-paginator

Pop Paginator Component for Pop PHP Framework

  • Monday, January 29, 2018
  • by nicksagona
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,117 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 12 Versions
  • 5 % Grown

The README.md

pop-paginator

Build Status Coverage Status, (*1)

Join the chat at https://discord.gg/TZjgT74U7E, (*2)

Overview

pop-paginator is a component for handling pagination for large data sets. You can set multiple options to control the display of the pages and the links., (*3)

pop-paginator is a component of the Pop PHP Framework., (*4)

Install

Install pop-paginator using Composer., (*5)

composer require popphp/pop-paginator

Or, require it in your composer.json file, (*6)

"require": {
    "popphp/pop-paginator" : "^4.0.2"
}

Top, (*7)

Quickstart

use Pop\Paginator\Paginator;

$paginator = Paginator::createRange(42); // Returns a Pop\Paginator\Range object
echo $paginator;

Which will produce this HTML:, (*8)

<span>1</span>
<a href="/?page=2">2</a>
<a href="/?page=3">3</a>
<a href="/?page=4">4</a>
<a href="/?page=5">5</a>

And if you clicked on page 3, it would render:, (*9)

<a href="/?page=1">1</a>
<a href="/?page=2">2</a>
<span>3</span>
<a href="/?page=4">4</a>
<a href="/?page=5">5</a>

Top, (*10)

Page Range

In the above example, a page range object renders a range of page links. With it, you can set a large number of pages and have it render "bookend" link before and after the range as the "previous" and "next" links. Pass the total number of items, the per page limit and the range limit:, (*11)

use Pop\Paginator\Paginator;

$paginator = Paginator::createRange(4512, 10, 10); // Returns a Pop\Paginator\Range object
echo $paginator;

If we go to page 12, it would render:, (*12)

<a href="/?page=1">&laquo;</a>
<a href="/?page=10">&lsaquo;</a>
<a href="/?page=11">11</a>
<span>12</span>
<a href="/?page=13">13</a>
<a href="/?page=14">14</a>
<a href="/?page=15">15</a>
<a href="/?page=16">16</a>
<a href="/?page=17">17</a>
<a href="/?page=18">18</a>
<a href="/?page=19">19</a>
<a href="/?page=20">20</a>
<a href="/?page=21">&rsaquo;</a>
<a href="/?page=452">&raquo;</a>

As you can see, it renders the "bookends" to navigate to the next set of pages, the previous set, the beginning or end of the set., (*13)

Top, (*14)

Page Form

To have a cleaner way of displaying a large set of pages, you can use the form object, which renders a input form field., (*15)

use Pop\Paginator\Form;
$paginator = new Form(558); // Returns a Pop\Paginator\Form object
echo $paginator;

This will produce:, (*16)

<a href="/?page=1">&laquo;</a>
<a href="/?page=13">&lsaquo;</a>
<form action="/" method="get">
    <div><input type="text" name="page" size="2" value="14" /> of 56</div>
</form>
<a href="/?page=15">&rsaquo;</a>
<a href="/?page=56">&raquo;</a>

So instead of a set a links in between the bookends, there is a form input field that will allow the user to input a specific page to jump to., (*17)

Top, (*18)

Options

You can set many options to tailor the paginator object's look and functionality:, (*19)

  • Number of items per page
  • Range of the page sets
  • Separator between the page links
  • Classes for the on/off page links
  • Bookend characters
    • start
    • previous
    • next
    • end
use Pop\Paginator\Form;
$paginator = new Form(558); // Returns a Pop\Paginator\Form object
$paginator->setBookends([
    'start'    => '&laquo;',
    'previous' => '&lsaquo;',
    'next'     => '&rsaquo;',
    'end'      => '&raquo;'
])

The start is the far left bookend that takes you back to the beginning. The previous is the left bookend that takes you to the previous page set. The next is the right bookend that takes you to the next page set. The end is the far right bookend that takes you all the way to the end., (*20)

Top, (*21)

The Versions

29/01 2018

v2.x-dev

2.9999999.9999999.9999999-dev http://www.popphp.org/

Pop Paginator Component for Pop PHP Framework

  Sources   Download

BSD-3-Clause New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php pagination paginator pop pop php

29/01 2018

dev-master

9999999-dev http://www.popphp.org/

Pop Paginator Component for Pop PHP Framework

  Sources   Download

BSD-3-Clause New BSD

The Requires

  • php >=5.6.0

 

The Development Requires

php pagination paginator pop pop php

29/01 2018

dev-v3-dev

dev-v3-dev http://www.popphp.org/

Pop Paginator Component for Pop PHP Framework

  Sources   Download

BSD-3-Clause New BSD

The Requires

  • php >=5.6.0

 

The Development Requires

php pagination paginator pop pop php

29/01 2018

3.0.2

3.0.2.0 http://www.popphp.org/

Pop Paginator Component for Pop PHP Framework

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6.0

 

The Development Requires

php pagination paginator pop pop php

21/06 2017

3.0.1

3.0.1.0 http://www.popphp.org/

Pop Paginator Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.6.0

 

The Development Requires

php pagination paginator pop pop php

08/03 2017

3.0.0

3.0.0.0 http://www.popphp.org/

Pop Paginator Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.6.0

 

The Development Requires

php pagination paginator pop pop php

03/10 2016

2.1.2

2.1.2.0 http://www.popphp.org/

Pop Paginator Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php pagination paginator pop pop php

05/07 2016

2.1.1

2.1.1.0 http://www.popphp.org/

Pop Paginator Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php pagination paginator pop pop php

01/07 2016

2.1.0

2.1.0.0 http://www.popphp.org/

Pop Paginator Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php pagination paginator pop pop php

10/05 2016

2.0.0p2

2.0.0.0-patch2 http://www.popphp.org/

Pop Paginator Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php pagination paginator pop pop php

19/02 2016

2.0.0p1

2.0.0.0-patch1 http://www.popphp.org/

Pop Paginator Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php pagination paginator pop pop php

21/07 2015

2.0.0

2.0.0.0 http://www.popphp.org/

Pop Paginator Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php pagination paginator pop pop php