venca-x / nette-pagination
Plugin for Nette. Twitter Bootsrap pagination
v1.0.1
2023-11-15 14:25 UTC
Requires
- php: >=7.1
- latte/latte: >=2.0
- nette/application: >=2.0
- nette/utils: ^3.0 || ^4.0
Requires (Dev)
- nette/bootstrap: ^3.0
- nette/robot-loader: ^3.0 || ^4.0
- nette/tester: ^2.0
- tracy/tracy: ^2.0
This package is auto-updated.
Last update: 2024-10-15 16:28:31 UTC
README
Plugin for Nette. Pagination with Twitter Bootstrap style Twitter Bootstrap Suports Twitter Bootstrap 3 and Twitter Bootstrap 4
Installation
install with composer:
composer require venca-x/nette-pagination:dev-master
Nette 3.0
For Nette 3.0 (and PHP >= 7.1) use:
composer require venca-x/nette-pagination:^1.0
//or
composer require venca-x/nette-pagination:dev-master
For Nette 2.4. and 2.3 use:
composer require venca-x/nette-pagination:^0.1
Configuration
HomepagePresenter.php
/** @var int shoved page in paginator */ private $paginatorOffset; public function actionMy() { //$vp = new VencaX\NettePagination\BootstrapRendererV4(); $vp = new VencaX\NettePagination\BootstrapRendererV4($this, 'vp'); $vp->setMaximalPagesCount( 5 );//maximal count pages in paginator $paginator = $vp->getPaginator(); $paginator->itemsPerPage = 20; $paginator->itemCount = $this->modelTweets->findAll()->count( "*" ); $this->paginatorOffset = $paginator->offset; $this->dataSelection = $this->modelTweets->findAll()->limit( $paginator->itemsPerPage, $paginator->offset ); //... } public function renderMy() { $this->template->paginatorOffset = $this->paginatorOffset; }
Usage
On all pages of paginator (without first) use meta robots noindex,follow
{block head} {if $paginatorOffset > 1} <meta name="robots" content="noindex,follow"> {/if} {/block} {block content} ... {control vp} ... {/block}
Tips
How to change labels « Předchozí and Další »?
Change it in the constructor:
$vp = new VencaX\NettePagination\BootstrapRendererV4(); $vp->setPreviousLabel('«'); $vp->setNextLabel('»'); //or $vp = new VencaX\NettePagination\BootstrapRendererV3(); $vp->setPreviousLabel('«'); $vp->setNextLabel('»');
TwitterBootstrap v3
How to use for TwitterBootstrap v3?
Usage is same as TwitterBootstrap v4. Only chnage class to VencaX\NettePagination\BootstrapRendererV3
/** @var int shoved page in paginator */ private $paginatorOffset; public function actionMy() { $vp = new VencaX\NettePagination\BootstrapRendererV3(); $vp->setMaximalPagesCount( 5 );//maximal count pages in paginator $paginator = $vp->getPaginator(); $paginator->itemsPerPage = 20; $paginator->itemCount = $this->modelTweets->findAll()->count( "*" ); $this->paginatorOffset = $paginator->offset; $this->dataSelection = $this->modelTweets->findAll()->limit( $paginator->itemsPerPage, $paginator->offset ); //... } public function renderMy() { $this->template->paginatorOffset = $this->paginatorOffset; }