1. Go to this page and download the library: Download ipub/visual-paginator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ipub / visual-paginator example snippets
useIPub\VisualPaginator\ComponentsasVisualPaginator;
classSomePresenterextendsNette\Application\UI\Presenter{
/**
* @var Model
*/private $dataModel;
publicfunctionrenderDefault(){
$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
*/protectedfunctioncreateComponentVisualPaginator(){
// Init visual paginator
$control = new VisualPaginator\Control;
return $control;
}
}