geniv / nette-visualpaginator
Addon to display paginator in Nette webapplications
Installs: 1 561
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 3
Open Issues: 0
Requires
- php: >= 5.6.0
- nette/nette: >= 2.3.0
This package is not auto-updated.
Last update: 2020-01-24 16:27:52 UTC
README
VisualPaginator is a component for the Nette Framework, that provides comfortable way to render pagination component on long listings.
Installation
The best way to install this component is throught Composer.
$ composer require geniv/nette-visualpaginator
composer.json:
"geniv/nette-visualpaginator": ">=1.0",
Using
- VisualPaginator
basic usage:
use VisualPaginator; ... /** @var VisualPaginator @inject */ public $visualPaginator; public function renderDefault() // for dibi $items = $this->model->getList(); $items = range(1, 150); $vp = $this->visualPaginator->getPaginator(); $vp->setItemCount(count($items)) ->setItemsPerPage(5); // for dibi $this->template->items = $items->limit($vp->getLength())->offset($vp->getOffset()); // for array $this->template->items = array_slice($items, $vp->getOffset(), $vp->getLength()) } protected function createComponentVisualPaginator() { return $this->visualPaginator; }
advance usage:
protected function createComponentVisualPaginator() { return $this->visualPaginator ->setPathTemplate(__DIR__ . '/templates/pagination.latte'); }
or use with Autowire (eg. geniv/nette-autowired)
use AutowireComponentFactories; use VisualPaginator; protected function createComponentVisualPaginator(VisualPaginator $visualPaginator) { return $visualPaginator; }
Calling it from templates
{control visualPaginator} or {control visualPaginator, count=>200, perPage=>5}
License
New BSD License
Authors
- Davig Grudl
- Igor Hlina
- Radek Fryšták