PHP code example of radekdostal / nette-visualpaginator

1. Go to this page and download the library: Download radekdostal/nette-visualpaginator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

radekdostal / nette-visualpaginator example snippets


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

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;
  }
}