Skip to content

Latest commit

 

History

History
64 lines (42 loc) · 1.06 KB

README.md

File metadata and controls

64 lines (42 loc) · 1.06 KB

Artfocus\VisualPaginator

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}