surda/visual-paginator

Visual paginator control for Nette Framework

v2.0.1 2024-10-15 08:41 UTC

This package is auto-updated.

Last update: 2024-10-15 08:44:01 UTC


README

Build Status Licence Latest stable PHPStan

Installation

The recommended way to is via Composer:

composer require surda/visual-paginator

After that you have to register extension in config.neon:

extensions:
    visualPaginator: Surda\VisualPaginator\DI\VisualPaginatorExtension

Configuration

Default

visualPaginator:
    edges: 1
    displayedPages: 7
    useAjax: FALSE
    templates:
        default: bootstrap4.default.latte
        default-ajax: bootstrap4.default.ajax.latte
        mini: bootstrap4.mini.latte

Usage

Presenter

use Surda\VisualPaginator\TVisualPaginator;
use Surda\VisualPaginator\VisualPaginatorControl;
use Nette\Utils\Paginator;

class ProductPresenter extends Nette\Application\UI\Presenter
{
    use TVisualPaginator;

    public function actionDefault(): void
    {
        /** @var VisualPaginatorControl $vp */
        $vp = $this->getComponent('vp');

        /** @var Paginator $paginator */
        $paginator = $vp->getPaginator();
        $paginator->setItemsPerPage(20);
        $paginator->setItemCount(500);

        // $rows->limit($paginator->getItemsPerPage(), $paginator->getOffset());
    }
}

Template

{control vp} or {control vp default} 

Custom options

class ProductPresenter extends Nette\Application\UI\Presenter
{
    /**
     * @return VisualPaginatorControl
     */
    protected function createComponentIpp(): VisualPaginatorControl
    {
        $control = $this->visualPaginatorFactory->create();

        $control->setEdges(1);
        $control->setDisplayedPages(7);
        $control->disableAjax();
        $control->enableAjax();

        return $control;
    }
}