EasyAdmin: Add page numbers to list view

KC Müller
1 min readAug 27, 2018

--

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:
/templates/bundles/EasyAdminBundle/default/paginator.html.twig
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

--

--