ssch / typo3-pagerfanta
Integrates pagerfanta into TYPO3
Fund package maintenance!
sabbelasichon
paypal.me/schreiberten
Installs: 1 446
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 4
Forks: 1
Open Issues: 4
Language:HTML
Type:typo3-cms-extension
Requires
- pagerfanta/core: ^3.5
- typo3/cms-core: ^11.5 || ^12.4
- typo3/cms-extbase: ^11.5 || ^12.4
- typo3/cms-fluid: ^11.5 || ^12.4
- webmozart/assert: ^1.10
Requires (Dev)
- jangregor/phpstan-prophecy: ^1.0
- php-parallel-lint/php-parallel-lint: ^1.3
- phpspec/prophecy-phpunit: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-strict-rules: ^1.0
- phpstan/phpstan-webmozart-assert: ^1.0
- rector/rector: ^0.18.2
- saschaegerer/phpstan-typo3: ^1.0
- symfony/serializer: ^4.4 || ^5.4 || ^6.0
- symplify/easy-coding-standard: ^11.0
- typo3/testing-framework: ^6.2
- dev-main
- v1.0.0
- v0.1.0
- v0.0.5
- v0.0.4
- v0.0.3
- 0.0.1
- dev-dependabot/composer/symplify/easy-coding-standard-tw-12.1
- dev-dependabot/composer/rector/rector-tw-0.19.5
- dev-dependabot/github_actions/peter-evans/create-pull-request-6.0.0
- dev-dependabot/github_actions/stefanzweifel/git-auto-commit-action-5.0.0
This package is auto-updated.
Last update: 2024-10-30 19:04:35 UTC
README
TYPO3 integration with Pagerfanta Library!
Extension to use Pagerfanta with TYPO3.
Installation & Setup
To install this bundle, run the following Composer command:
composer require ssch/typo3-pagerfanta
Default configuration
plugin.tx_typo3pagerfanta { settings { # The default Pagerfanta view to use in your application default_view = fluid # The default fluid template to use when using the Twig Pagerfanta view (available: Foundation6, MaterializeCss, Tailwind, TwitterBootstrap, TwitterBootstrap3, TwitterBootstrap4, TwitterBootstrap5 default_fluid_template = EXT:typo3_pagerfanta/Resources/Private/Templates/TwitterBootstrap5.html } }
How to use by examples
Imagine you have a classic extbase plugin with an extbase repository query result you want to paginate, then you can use the following example as a starter.
use Psr\Http\Message\ResponseInterface; final class TestController extends ActionController { public function myCustomAction(int $currentPage = 1): ResponseInterface { $jobs = $this->jobRepository->findAll(); $queryResultAdapter = new QueryResultAdapter($jobs); $pagination = Pagerfanta::createForCurrentPageWithMaxPerPage($queryResultAdapter, $currentPage, 1); $this->view->assign('pagination', $pagination); return $this->htmlRepsonse(); } }
You then call the PaginationViewHelper in your Fluid template, passing in the Pagination instance. The routes are generated automatically for the current route using the variable "currentPage" to propagate the page number. By default, the extension uses the FluidView with the TwitterBootstrap5 template to render the pagination.
{namespace pagerfanta = Ssch\Typo3Pagerfanta\ViewHelpers} <pagerfanta:pagination pagerfanta="{pagination}" /> <f:for each="{pagination}" as="job"> <f:render partial="List" arguments="{job: job}"/> </f:for> <pagerfanta:pagination pagerfanta="{pagination}" />
If you are using a parameter other than currentPage for pagination, you can set the parameter name by using the pageParameter option when rendering the pager.
<pagerfanta:pagination pagerfanta="{pagination}" options="{pageParameter: 'page'}" />
If you want to use a different template for the pagination you can set the template by using the template option when rendering the pager.
<pagerfanta:pagination pagerfanta="{pagination}" options="{template: 'EXT:typo3_pagerfanta/Resources/Private/Templates/Foundation6.html'}" />
Why this extension shines
In my opinion this extension or better to say the Pagerfanta concept separates the route generation (RouteGenerator) from the view. So the view is totally agnostic about how to generate the page links itself and so it is fully reusable. To generate the routes inside the controller offers more flexibility instead of generating the page links inside the view itself.
Further Documentation
Please see the BabDev website for detailed information on how to use this extension.
Acknowledgment
This package is heavily inspired by babdev/pagerfanta-bundle by Michael Babker. Thank you.