2017 © Pedro Peláez
 

library puja-paginator

Puja-Paginator is a flexible component for paginating collections of data and presenting that data to users.

image

jinnguyen/puja-paginator

Puja-Paginator is a flexible component for paginating collections of data and presenting that data to users.

  • Wednesday, January 18, 2017
  • by jinnguyen
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

puja-paginator

Puja-Paginator is a flexible component for paginating collections of data and presenting that data to users., (*1)

Installation

Just run this on the command line:, (*2)

composer require jinnguyen/puja-paginator

Usage

include '/path/to/vendor/autoload.php';
use Puja\Paginator\Paginator;

Examples:

Simple, (*3)

$paginator = new Paginator(
    '/news/', // url
    100, // total of records
    10 // number of records per page
);

The rest of the documentation will assume you have a $paginator instance on which you are making calls., (*4)

Adding renderer

$paginator->addRenderer('simple', 'Puja\Paginator\Renderer\Simple'); // Puja\Paginator\Renderer\Simple must be extended of Puja\Paginator\Renderer\RendererAbstract

Set labels

$paginator->setLabels($labes); // default $labels is [First, Prev, Next, Last]

First,Last and Current CSS classes

    
  • Home
  • // First element
  • Page
  • Subpage
  • // Current Element
  • Subpage 2
  • // Last Element

The first/last css classes are the class of first/last Breadcrumb element, (*5)

$paginator->setFirstCssClassName($className);
$paginator->setLastCssClassName($className);
$paginator->setCurrentCssClassName($className);

The Element

The default paging element is <li class="{CssClassName}">%s{Divider}</li>. To change it, use the setElement method like so:, (*6)

$paginator->setElement('<span class="{FirstLastCss}">%s{Divider}</span>');

Note:, (*7)

"%s" is required for Paginator::$element
{CssClassName}: will be replaced by Paginator::$firstCssClassName/Paginator::$currentCssClassName/Paginator::$lastCssClassName if this element is first/current/last element.
{Divider}: will be replaced by Paginator::$divider

The List Element

The default list element used to wrap the paging, is <ul>%s</ul>. To change it, use the setListElement method like so:, (*8)

$paginator->setListElement('<ol class="ol-paging">%s</ol>');

Note:, (*9)

"%s" is required for Paginator::$listElement

Divider

The default divider is `` (empty). This will be replace to placeholder {Divider} in property Paginator::$element. If you'd like to change it to, for example, /, you can just do:, (*10)

$paginator->setDivider('/');

Output

Finally, when you actually want to display your breadcrumbs, all you need to do is call the render() method on the instance:, (*11)

echo $paginator->render('simple');
echo $paginator->render('basic');
echo $paginator->render(); // default is `basic`

Note, (*12)

You can write custom Renderer by yourself. You can check Puja\Paginator\Renderer\Simple as a sample

Example, (*13)

class CustomRenderer extends \Puja\Paginator\Renderer\RendererAbstract
{
    public function parse()
    {
        $p = '';
        for ($i = 0; $i < $this->paginator->getTotalPage(); $i++) {
            $p .= $this->paginator->getPageElement($i, true);
        }

        return $p;
    }
}

$paginator->addRenderer('custom', 'CustomRenderer');
$paginator->render('custom');

Note that by default First/Prev/Next/Last titles are rendered with escaping HTML characters, if you'd like to ignore it just do like so:, (*14)

$paginator->setSafeHtml(false);

The Versions

18/01 2017

dev-master

9999999-dev

Puja-Paginator is a flexible component for paginating collections of data and presenting that data to users.

  Sources   Download

Apache License 2.0

by Jin Nguyen

paginator puja

18/01 2017

v1.0.0

1.0.0.0

Puja-Paginator is a flexible component for paginating collections of data and presenting that data to users.

  Sources   Download

Apache License 2.0

by Jin Nguyen

paginator puja