artfocus/visual-paginator

Visual Paginator for Nette Framework

v1.0.2 2016-07-05 17:43 UTC

This package is not auto-updated.

Last update: 2024-10-12 19:49:36 UTC


README

Installation

$ composer require artfocus/visual-paginator

Setup

Register Artfocus\VisualPaginator\VisualPaginatorFactory as a Service in your DI.

# app/config.neon

services:
	- Artfocus\VisualPaginator\VisualPaginatorFactory

Example usage (with Doctrine)

<?php

namespace App\Presenters;

use App\Facade\ArticleFacade;
use Artfocus\VisualPaginator;

class ArticlePresenter extends BasePresenter
{

	use VisualPaginator\VisualPaginatorTrait;

	/**
	 * @var ArticleFacade
	 * @inject
	 */
	public $articleFacade;

	public function renderDefault()
	{
		// Get instance of Doctrine\ORM\Tools\Pagination\Paginator
		$articles = $this->articleFacade->findByTag('new');
		
		// Apply pagination - 10 items per page.
		$this->template->articles = VisualPaginator\DoctrineHelper::apply($articles, $this->getComponent('paginator'), 10);
	}

}
{* Article/default.latte *}

{block content}
	<ul n:inner-foreach="$articles as $article">
		<li>{$article->getTitle()}</li>
	</ul>

	{control paginator}
{/block}