aleswita/visualpaginator

VisualPaginator for Nette Framework.

v4.0.2 2021-04-06 11:56 UTC

This package is auto-updated.

Last update: 2024-11-10 16:19:18 UTC


README

Visual Paginator for Nette Framework.

Build Status Coverage Status PHPStan

Installation

The best way to install AlesWita/VisualPaginator is using Composer:

$ composer require aleswita/visualpaginator

Usage

Neon

services:
	- AlesWita\VisualPaginator\VisualPaginatorFactory

Presenter

<?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;
	}

}

Template

{control paginator}

Custom paginator template

{templateType AlesWita\VisualPaginator\Template}
...