zeleznypa / jao-nette-visual-paginator
This package is abandoned and no longer maintained.
No replacement package was suggested.
Just another one visual paginator component for Nette framework
0.1.0
2014-03-17 21:13 UTC
Requires
- php: >=5.3.0
- nette/nette: >= 2.1.1
This package is not auto-updated.
Last update: 2016-01-06 08:26:45 UTC
README
Pavel Železný (2bfree), 2013 (pavelzelezny.cz)
Requirements
Nette Framework 2.1.1 or higher. PHP 5.3 edition
Documentation
Just another one visual paginator component for Nette framework based on original VisualPaginator from David Grudl.
Some features added:
- Default template is Twitter bootstrap 3 compatible.
- Text strings are translateable.
- Switch page is handled by Nette ajax.
- Support of setting additional event.
- Possibility of changing template.
- Possibility of setting count of vissible pages.
Instalation
Prefered way to intall is by Composer
{
"require":{
"zeleznypa/jao-nette-visual-paginator": "dev-master"
}
}
Setup
Add following code into neon.conf
common:
services:
paginatorFactory:
implement: \Zeleznypa\Nette\Utils\IPaginatorFactory
visualPaginatorFactory:
implement: \Zeleznypa\Nette\Utils\IVisualPaginatorFactory
Usage
After instalation you can simply set dependency on IVisualPaginatorFacotry by constructor property or inject method(cs manual) in presenter.
<?php
/**
* Base presenter for all application presenters.
*/
class TestPresenter extends \Nette\Application\UI\Presenter
{
/** @var \Zeleznypa\Nette\Utils\IVisualPaginatorFactory */
protected $visualPaginatorFactory;
/**
* Visual paginator injection
* @author Pavel Železný <info@pavelzelezny.cz>
* @param \Zeleznypa\Nette\Utils\IVisualPaginatorFactory $visualPaginatorFactory
* @return TestPresenter Provides fluent interface
* @throws \Nette\InvalidStateException
*/
public function injectVisualPaginatorFactory(\Zeleznypa\Nette\Utils\IVisualPaginatorFactory $visualPaginatorFactory)
{
if ($this->visualPaginatorFactory !== NULL)
{
throw new \Nette\InvalidStateException('Visual paginator factory has already been set');
}
$this->visualPaginatorFactory = $visualPaginatorFactory;
return $this;
}
/**
* Visual paginator component factory
* @author Pavel Železný <info@pavelzelezny.cz>
* @return \Zeleznypa\Nette\Utils\VisualPaginator
*/
protected function createComponentVisualPaginator()
{
$visualPaginator = $this->getVisualPaginatorFactory()->create();
$visualPaginator->getPaginator()->setItemsPerPage(10);
$visualPaginator->onSwitch[] = callback($this, 'redrawPaginatedList');
return $visualPaginator;
}
/**
* Redraw snippet with list of paginated data
* @author Pavel Železný <info@pavelzelezny.cz>
* @return void
*/
protected function redrawPaginatedList()
{
$this->redrawComponent('PaginatedList');
}
/**
* Visual paginator getter
* @author Pavel Železný <info@pavelzelezny.cz>
* @return \Zeleznypa\Nette\Utils\IVisualPaginatorFactory
*/
public function getVisualPaginatorFactory()
{
return $this->visualPaginatorFactory;
}
}
In Latte templates you can use standard component renderer
{control visualPaginator}