Last active
May 6, 2026 15:18
-
-
Save kitzberger/4665c523ed7fcd9cbf1ce12d6c7ba4d8 to your computer and use it in GitHub Desktop.
Extbase 12 Paginator (Replacement for f:widget.paginate)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <ul> | |
| <f:for each="{paginator.paginatedItems}" as="record" iteration="iterator"> | |
| <li>{record.uid}</li> | |
| </f:for> | |
| </ul> | |
| <f:render partial="Pagination" arguments="{ | |
| pagination:pagination, | |
| currentPage:currentPage, | |
| additionalParams:{} | |
| }" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <f:if condition="{pagination.paginator.numberOfPages} > 1"> | |
| <ul class="pagination"> | |
| <f:if condition="{currentPage} == 1"> | |
| <f:then> | |
| <li class="previous disable"> | |
| < | |
| </li> | |
| </f:then> | |
| <f:else> | |
| <li class="previous"> | |
| <f:link.action | |
| arguments="{currentPage:'{currentPage - 1}'}" | |
| additionalParams="{additionalParams}" | |
| aria-label="Seite {currentPage - 1}" | |
| aria-current="false" | |
| > | |
| < | |
| </f:link.action> | |
| </li> | |
| </f:else> | |
| </f:if> | |
| <f:if condition="{pagination.displayRangeStart} > 1"> | |
| <li> | |
| <f:link.action | |
| arguments="{currentPage:1}" | |
| additionalParams="{additionalParams}" | |
| aria-label="Seite 1" | |
| aria-current="false" | |
| > | |
| 1 | |
| </f:link.action> | |
| </li> | |
| </f:if> | |
| <f:if condition="{pagination.hasLessPages}"> | |
| <li>...</li> | |
| </f:if> | |
| <f:for each="{pagination.allPageNumbers}" as="page"> | |
| <li class="{f:if(condition:'{currentPage}=={page}',then:'active')}"> | |
| <f:link.action | |
| arguments="{currentPage:page}" | |
| additionalParams="{additionalParams}" | |
| aria-label="Seite {page}" | |
| aria-current="{f:if(condition:'{currentPage}=={page}',then:'true',else:'false')}" | |
| > | |
| {page} | |
| </f:link.action> | |
| </li> | |
| </f:for> | |
| <f:if condition="{pagination.hasMorePages}"> | |
| <li>...</li> | |
| </f:if> | |
| <f:if condition="{pagination.displayRangeEnd} < {pagination.paginator.numberOfPages}"> | |
| <li> | |
| <f:link.action | |
| arguments="{currentPage:pagination.paginator.numberOfPages}" | |
| additionalParams="{additionalParams}" | |
| aria-label="Seite {pagination.paginator.numberOfPages}" | |
| aria-current="false" | |
| > | |
| {pagination.paginator.numberOfPages} | |
| </f:link.action> | |
| </li> | |
| </f:if> | |
| <f:if condition="{currentPage} == {pagination.paginator.numberOfPages}"> | |
| <f:then> | |
| <li class="next disable"> | |
| > | |
| </li> | |
| </f:then> | |
| <f:else> | |
| <li class="next"> | |
| <f:link.action | |
| arguments="{currentPage:'{currentPage + 1}'}" | |
| additionalParams="{additionalParams}" | |
| aria-label="Seite {currentPage + 1}" | |
| aria-current="false" | |
| > | |
| > | |
| </f:link.action> | |
| </li> | |
| </f:else> | |
| </f:if> | |
| </ul> | |
| </f:if> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class RecordController extends ActionController | |
| { | |
| public function indexAction(): ResponseInterface | |
| { | |
| $records = $this->recordRepository->findAll(); | |
| $currentPage = $this->request->hasArgument('currentPage') | |
| ? (int)$this->request->getArgument('currentPage') | |
| : 1; | |
| $itemsPerPage = 8; | |
| $maximumLinks = 3; | |
| $paginator = new QueryResultPaginator( | |
| $records, | |
| $currentPage, | |
| $itemsPerPage, | |
| ); | |
| $pagination = new SlidingWindowPagination( | |
| $paginator, | |
| $maximumLinks, | |
| ); | |
| $this->view->assignMultiple([ | |
| 'currentPage' => $currentPage, | |
| 'pagination' => $pagination, | |
| 'paginator' => $paginator, | |
| 'records' => $records, | |
| ]); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment