gpslab / pagination-bundle
Pagination bundle
Installs: 594
Dependents: 0
Suggesters: 1
Security: 0
Stars: 11
Watchers: 2
Forks: 2
Open Issues: 4
Type:symfony-bundle
Requires
- php: >=5.4.0
- doctrine/orm: ~2.4|~2.5|~2.6
- sensio/framework-extra-bundle: ~3.0|~4.0|~5.0
- symfony/config: ~2.3|~3.0|~4.0|~5.0
- symfony/dependency-injection: ~2.3|~3.0|~4.0|~5.0
- symfony/expression-language: ~2.3|~3.0|~4.0|~5.0
- symfony/http-kernel: ~2.3|~3.0|~4.0|~5.0
- symfony/routing: ~2.3|~3.0|~4.0|~5.0
- symfony/yaml: ~2.3|~3.0|~4.0|~5.0
- twig/twig: ^1.34|^2.0|^3.0
Requires (Dev)
- phpunit/phpunit: ^4.8.36
README
PaginationBundle
Installation
Pretty simple with Composer, run:
composer req gpslab/pagination-bundle
Configuration
Default configuration
gpslab_pagination: # Page range used in pagination control max_navigate: 5 # Name of URL parameter for page number parameter_name: 'page' # Sliding pagination controls template template: 'GpsLabPaginationBundle::pagination.html.twig'
Simple usage
use GpsLab\Bundle\PaginationBundle\Service\Configuration; class ArticleController extends Controller { private const ARTICLES_PER_PAGE = 30; public function index(ArticleRepository $rep, Configuration $pagination): Response { $pagination->setTotalPages(ceil($rep->getTotalPublished() / self::ARTICLES_PER_PAGE)); // get articles chunk $offset = ($pagination->getCurrentPage() - 1) * self::ARTICLES_PER_PAGE; $articles = $rep->getPublished(self::ARTICLES_PER_PAGE, $offset); return $this->render('AcmeDemoBundle:Article:index.html.twig', [ 'articles' => $articles, 'pagination' => $pagination ]); } }
Display pagination in template:
<nav class="pagination"> {{- pagination_render(pagination) -}} </nav>
Documentation
- Base usage
- From QueryBuilder
- From HTTP request
- From HTTP request and QueryBuilder
- Request parameter name
- Navigation pages range
- Custom view
License
This bundle is under the MIT license. See the complete license in the file: LICENSE