PHP code example of jinnguyen / puja-paginator

1. Go to this page and download the library: Download jinnguyen/puja-paginator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jinnguyen / puja-paginator example snippets



use Puja\Paginator\Paginator;

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

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

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

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

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

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

$paginator->setDivider('/');

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

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');

$paginator->setSafeHtml(false);