.. include:: /Includes.rst.txt ========== Pagination ========== EXT:glossary2 comes with its own little pagination to navigate to `first`, `previous`, `next` and `last` page. If you need something more complex like `1, 2 ... 56, 57, 58 ... 123, 124` you should use another pagination library or build your own one. In the next steps I explain you how to implement the solution of Georg Ringers numbered_pagination. .. rst-class:: bignums 1. Add or modify Configuration/Services.yaml .. code-block:: none services: _defaults: autowire: true autoconfigure: true public: false JWeiland\SitePackage\: resource: '../Classes/*' JWeiland\SitePackage\EventListener\AddPaginatorEventListener: tags: - name: event.listener event: JWeiland\Glossary2\Event\PostProcessFluidVariablesEvent 2. Create EventListener Create file `Classes/EventListener/AddPaginatorEventListener.php` with following content: .. code-block:: php [ 'list', ], ]; public function __invoke(PostProcessFluidVariablesEvent $event): void { if ( $this->isValidRequest($event) && $event->getFluidVariables()['glossaries'] instanceof QueryResultInterface ) { // Reset $queryResult back to ALL records $queryResult = $event ->getFluidVariables()['glossaries'] ->getQuery() ->unsetLimit(0) ->setOffset(0) ->execute(); $paginator = new QueryResultPaginator( $queryResult, $this->getCurrentPage($event), $this->getItemsPerPage($event) ); $event->addFluidVariable('actionName', $event->getActionName()); $event->addFluidVariable('paginator', $paginator); $event->addFluidVariable('glossaries', $paginator->getPaginatedItems()); $event->addFluidVariable('pagination', new NumberedPagination($paginator)); } } protected function getCurrentPage(PostProcessFluidVariablesEvent $event): int { $currentPage = 1; if ($event->getRequest()->hasArgument('currentPage')) { // $currentPage have to be positive and greater than 0 // See: AbstractPaginator::setCurrentPageNumber() $currentPage = MathUtility::forceIntegerInRange( (int)$event->getRequest()->getArgument('currentPage'), 1 ); } return $currentPage; } protected function getItemsPerPage(PostProcessFluidVariablesEvent $event): int { $itemsPerPage = $this->itemsPerPage; if (isset($event->getSettings()['pageBrowser']['itemsPerPage'])) { $itemsPerPage = $event->getSettings()['pageBrowser']['itemsPerPage']; } return (int)$itemsPerPage; } } 3. Change path to glossary2 partials Set constant `partialRootPath` to a location within your SitePackage: .. code-block:: typoscript plugin.tx_glossary2.view.partialRootPath = EXT:site_package/Resources/Private/Extensions/Glossary2/Partials/ 4. Create Pagination template Create file `Resources/Private/Extensions/Glossary2/Partials/Component/Pagination.html` with example content from numbered_pagination https://github.com/georgringer/numbered_pagination/blob/master/Resources/Private/Partials/Pagination.html .. code-block:: html 5. Flush Cache in Installtool Needed to activate our new EventListener from Services.yaml. Clear Cache from the upper right (flash) is not enough.