geniv/nette-visualpaginator

This package is abandoned and no longer maintained. No replacement package was suggested.

Addon to display paginator in Nette webapplications

v1.0.2 2017-03-13 21:27 UTC

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