EasyAdmin: Add page numbers to list view

KC Müller
Aug 27, 2018 · 1 min read
Image for post
Image for post

The original EasyAdmin paginator template does not include the page numbers, but only the “first”, “previous”, “next” and “last” buttons. Since EasyAdmin uses the popular PagerFanta paginator bundle, it is quite easy to add the missing parts for showing the page numbers in the template.

Since there are no blocks defined in the paginator template, you will have to copy the whole template to your local application template folder and add the changes here. Below is the complete template file including the code for adding the page numbers. The custom code is inspired by https://gist.github.com/SimonSimCity/4594748

For a Symfony 4 application, create the template here:
Symfony will automatically apply the new template.

You can change the amount of previous and next pages displayed by setting the value of the nearbyPagesLimit variable.

Edit: I created a pull request to the EasyAdminBundle to get the pagination nicely integrated and configurable. It would be nice to get a thumb up or a comment to get it merged :) https://github.com/EasyCorp/EasyAdminBundle/pull/2338/files

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store