Skip to content

Latest commit

 

History

History
67 lines (52 loc) · 1.77 KB

readme.md

File metadata and controls

67 lines (52 loc) · 1.77 KB

Visual Paginator

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}
...