2017 © Pedro Peláez
 

library visual-paginator

Visual paginator for Nette Framework

image

ipub/visual-paginator

Visual paginator for Nette Framework

  • Monday, July 2, 2018
  • by akadlec
  • Repository
  • 2 Watchers
  • 6 Stars
  • 66,742 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 9 Forks
  • 2 Open issues
  • 9 Versions
  • 8 % Grown

The README.md

Visual Paginator

Build Status Scrutinizer Code Quality Latest Stable Version Composer Downloads, (*1)

Visual paginator for Nette Framework, (*2)

Installation

The best way to install ipub/visual-paginator is using Composer:, (*3)

{
    "require": {
        "ipub/visual-paginator": "dev-master"
    }
}

or, (*4)

$ composer require ipub/visual-paginator:@dev

After that you have to register extension in config.neon., (*5)

extensions:
    visualPaginator: IPub\VisualPaginator\DI\VisualPaginatorExtension

Usage

Implementing into Presenter or Component

use IPub\VisualPaginator\Components as VisualPaginator;

class SomePresenter extends Nette\Application\UI\Presenter
{
    /**
     * @var Model
     */
    private $dataModel;

    public function renderDefault()
    {
        $someItemsList = $this->dataModel->findAll();

        // Get visual paginator components
        $visualPaginator = $this['visualPaginator'];
        // Get paginator form visual paginator
        $paginator = $visualPaginator->getPaginator();
        // Define items count per one page
        $paginator->itemsPerPage = 10;
        // Define total items in list
        $paginator->itemCount = $someItemsList->count();
        // Apply limits to list
        $someItemsList->limit($paginator->itemsPerPage, $paginator->offset);
    }

    /**
     * Create items paginator
     *
     * @return VisualPaginator\Control
     */
    protected function createComponentVisualPaginator()
    {
        // Init visual paginator
        $control = new VisualPaginator\Control;

        return $control;
    }
}

Enabling or disabling ajax support

This component bring ajax support. When ajax is enabled, then ajax class is inserted into links., (*6)

use IPub\VisualPaginator\Components as VisualPaginator;

class SomePresenter extends Nette\Application\UI\Presenter
{
    /**
     * Create items paginator
     *
     * @return VisualPaginator\Control
     */
    protected function createComponentVisualPaginator()
    {
        // Init visual paginator
        $control = new VisualPaginator\Control;

        // Enable ajax (by default)
        $control->enableAjax();

        // Or disable ajax
        $control->disableAjax();

        return $control;
    }
}

And now you have to define events what to do when next or previous page is loaded via Ajax request:, (*7)

use IPub\VisualPaginator\Components as VisualPaginator;

class SomePresenter extends Nette\Application\UI\Presenter
{
    public function renderDefault()
    {
        $that = $this;

        //....

        // Define event for example to redraw snippets
        $this['visualPaginator']->onShowPage[] = (function ($component, $page) use ($that) {
            if ($that->isAjax()){
                $that->invalidateControl();
            }
        });
    }
}

Using templates

This component come with two default templates. One is basic default template, with some basic classes and the second one is Bootstrap FW template. And also you can use your own template:, (*8)

use IPub\VisualPaginator\Components as VisualPaginator;

class SomePresenter extends Nette\Application\UI\Presenter
{
    /**
     * Create items paginator
     *
     * @return VisualPaginator\Control
     */
    protected function createComponentVisualPaginator()
    {
        // Init visual paginator
        $control = new VisualPaginator\Control;

        // To use bootstrap default template
        $control->setTemplateFile('bootstrap.latte');

        // To use your own template
        $control->setTemplateFile('path/to/your/latte/file.latte');

        return $control;
    }
}

The Versions

30/01 2015

v1.0.0

1.0.0.0 https://github.com/iPublikuj/visual-paginator.git

Visual paginator for Nette Framework

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

The Development Requires

paging nette tools paginator ipub ipublikuj