surda / visual-paginator
Visual paginator control for Nette Framework
v2.0.1
2024-10-15 08:41 UTC
Requires
- php: >=7.1
- nette/di: ^3.0
- surda/themeable-controls: ^1.0
Requires (Dev)
- nette/tester: ^2.0
- ninjify/nunjuck: 0.3
- phpstan/phpstan: ^0.12
- phpstan/phpstan-deprecation-rules: ^0.12
- phpstan/phpstan-nette: ^0.12
- phpstan/phpstan-strict-rules: ^0.12
This package is auto-updated.
Last update: 2024-10-15 08:44:01 UTC
README
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; } }