Visual Paginator for Nette Framework.
The best way to install AlesWita/VisualPaginator is using Composer:
$ composer require aleswita/visualpaginator
services:
- AlesWita\VisualPaginator\VisualPaginatorFactory
<?php declare(strict_types = 1);
use AlesWita\VisualPaginator\VisualPaginator;
use AlesWita\VisualPaginator\VisualPaginatorFactory;
use Nette\Application\UI\Presenter;
final class HomePresenter extends Presenter
{
/** @inject */
public VisualPaginatorFactory $visualPaginatorFactory;
public function actionDefault(): void
{
$this['paginator']->setItemCount(1000);
$offset = $this['paginator']->getOffset();
$itemsPerPage = $this['paginator']->getItemsPerPage();
['SELECT * FROM `orders` LIMIT ? OFFSET ?', $itemsPerPage, $offset];
}
protected function createComponentPaginator(): VisualPaginator
{
$paginator = $this->visualPaginatorFactory->create();
$paginator->ajax = true;
$paginator->canSetItemsPerPage = true;
$paginator->templateFile = __DIR__ . '/my_awesome_template.latte';
return $paginator;
}
}
{control paginator}
{templateType AlesWita\VisualPaginator\Template}
...