Skip to content

aleswita/VisualPaginator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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