radekdostal/nette-visualpaginator

VisualPaginator Control for Nette Framework

2.0.0 2015-11-04 06:37 UTC

This package is auto-updated.

Last update: 2024-10-20 04:05:15 UTC


README

VisualPaginator Control for Nette Framework

This add-on creates visual paginator with localizations and with optional "all" button. It supports custom localizations and custom templates (default template is designed for Bootstrap 3).

Requirements

GNU Lesser General Public License

LGPL licenses are very very long, so instead of including them here we offer you URLs with full text:

Example

config.neon

extensions:
  translation: Kdyby\Translation\DI\TranslationExtension
  visualPaginator: RadekDostal\NetteComponents\VisualPaginator\VisualPaginatorExtension

translation:
  default: cs
  fallback: [cs_CZ, cs]
  whitelist: [cs, en]
  resolvers: # optional
    header: off

visualPaginator:
  translator: @translation.default
  #template: '%appDir%/components/VisualPaginator/custom.latte'
  #viewButtonAll: TRUE

Kdyby\Translation looks for localizations in the directory app/lang. For example english localization file must be named visualPaginator.en_GB.neon (in case of using the NEON syntax).

Presenter

class DefaultPresenter extends BasePresenter
{
  use \RadekDostal\NetteComponents\VisualPaginator\TVisualPaginator;

  public function renderDefault()
  {
    $paginator = $this['vp']->getPaginator();
    $paginator->setItemsPerPage(1);
    $paginator->setItemCount(10);
  }

  /**
   * Creates the visual paginator
   *
   * @return \RadekDostal\NetteComponents\VisualPaginator\VisualPaginator
   */
  protected function createComponentVp()
  {
    return $this->visualPaginator;
  }

  // For multiple paginators on the same page
  protected function createComponentVp2()
  {
    $control = $this->visualPaginator->create();
    // $control->setTemplate(...);
    
    // Dynamic change localization
    $control->getTranslator()->setLocale('en');
    
    return $control;
  }
}

Template default.latte

{control vp}