diff --git a/Classes/Controller/ProductController.php b/Classes/Controller/ProductController.php index 2b4c372a..3de9b150 100644 --- a/Classes/Controller/ProductController.php +++ b/Classes/Controller/ProductController.php @@ -17,7 +17,7 @@ use Extcode\CartProducts\Domain\Repository\CategoryRepository; use Extcode\CartProducts\Domain\Repository\Product\ProductRepository; use Psr\Http\Message\ResponseInterface; -use TYPO3\CMS\Core\Pagination\SimplePagination; +use TYPO3\CMS\Core\Pagination\SlidingWindowPagination; use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; @@ -154,19 +154,20 @@ public function listAction(int $currentPage = 1): ResponseInterface $demand = $this->createDemandObjectFromSettings($this->settings); $demand->setActionAndClass(__METHOD__, self::class); - $itemsPerPage = $this->settings['itemsPerPage'] ?? 20; + $itemsPerPage = (int)($this->settings['itemsPerPage'] ?? 20); + $maximumNumberOfLinks = (int)($this->settings['maximumNumberOfLinks'] ?? 0); $products = $this->productRepository->findDemanded($demand); - $arrayPaginator = new QueryResultPaginator( + $paginator = new QueryResultPaginator( $products, $currentPage, $itemsPerPage ); - $pagination = new SimplePagination($arrayPaginator); + $pagination = new SlidingWindowPagination($paginator, $maximumNumberOfLinks); $this->view->assignMultiple( [ 'products' => $products, - 'paginator' => $arrayPaginator, + 'paginator' => $paginator, 'pagination' => $pagination, 'pages' => range(1, $pagination->getLastPageNumber()), ] diff --git a/Documentation/Administrator/Configuration/TypoScript/Index.rst b/Documentation/Administrator/Configuration/TypoScript/Index.rst index 2327d5e0..304f03ae 100644 --- a/Documentation/Administrator/Configuration/TypoScript/Index.rst +++ b/Documentation/Administrator/Configuration/TypoScript/Index.rst @@ -25,6 +25,7 @@ EXT:cart. format.currency < plugin.tx_cart.settings.format.currency itemsPerPage = 9 + maximumNumberOfLinks = 0 } } @@ -49,3 +50,10 @@ the individual parameter are described. :Default: The default value is 20 if there is no TypoScript configuration. Defines how many records should be displayed per page in the list action. + +.. confval:: maximumNumberOfLinks + + :Type: int + :Default: The default value is 0 if there is no TypoScript configuration. + + Defines how many links the paginator should show. The default value 0 means that the page links are not limited. diff --git a/Documentation/Changelog/6.1/Feature-259-ReplaceSimplePaginationWithSlidingWindowPagination.rst b/Documentation/Changelog/6.1/Feature-259-ReplaceSimplePaginationWithSlidingWindowPagination.rst new file mode 100644 index 00000000..9f559c72 --- /dev/null +++ b/Documentation/Changelog/6.1/Feature-259-ReplaceSimplePaginationWithSlidingWindowPagination.rst @@ -0,0 +1,28 @@ +.. include:: ../../Includes.rst.txt + +===================================================================== +Feature: #259 - Replace SimplePagination with SlidingWindowPagination +===================================================================== + +See `Issue 259 `__ + +Description +=========== + +If you have a long list of products, you would like to display them in a pagination +with a defined number of products per page. This is already possible with the +TypoScript configuration `itemsPerPage`. With a large number of products, the +display of all page links may not work well, especially when it comes to the +display on mobile devices. +The TYPO3 core offers the SlidingWindowPagination since TYPO3 v12. +This is compatible with the previously used SimplePagination if you pass the +value 0 for the number of links. + +Integration +=========== + +Set the new TypoScript configuration variable `plugin.tx_cartproducts.maximumNumberOfLinks` to a value greater than 0. +If you use an own template file for `Resources/Private/Partials/Utility/Paginator.html` you have to adapt the changes +to your file. + +.. index:: Frontend diff --git a/Documentation/Changelog/6.1/Index.rst b/Documentation/Changelog/6.1/Index.rst new file mode 100644 index 00000000..53a1b9ea --- /dev/null +++ b/Documentation/Changelog/6.1/Index.rst @@ -0,0 +1,20 @@ +.. include:: ../../Includes.rst.txt + +6.1 Changes +=========== + +**Table of contents** + +.. contents:: + :local: + :depth: 1 + +Features +^^^^^^^^ + +.. toctree:: + :maxdepth: 1 + :titlesonly: + :glob: + + Feature-* diff --git a/Documentation/Changelog/Index.rst b/Documentation/Changelog/Index.rst index b5646b6e..54941eb2 100644 --- a/Documentation/Changelog/Index.rst +++ b/Documentation/Changelog/Index.rst @@ -10,6 +10,7 @@ ChangeLog :maxdepth: 5 :titlesonly: + 6.1/Index 6.0/Index 5.0/Index 4.0/Index diff --git a/Documentation/guides.xml b/Documentation/guides.xml index e4fad22e..164d1fd2 100644 --- a/Documentation/guides.xml +++ b/Documentation/guides.xml @@ -11,9 +11,9 @@ interlink-shortcode="extcode/cart_products" /> diff --git a/Resources/Private/Partials/Utility/Paginator.html b/Resources/Private/Partials/Utility/Paginator.html index 882a1dd7..e01323e0 100644 --- a/Resources/Private/Partials/Utility/Paginator.html +++ b/Resources/Private/Partials/Utility/Paginator.html @@ -17,12 +17,21 @@
  • - + + +
  • +
    + +
  • {page}
  • + +
  • +
    +
  • @@ -39,4 +48,4 @@ - \ No newline at end of file + diff --git a/ext_emconf.php b/ext_emconf.php index c8d957f7..b31a5299 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -4,7 +4,7 @@ 'title' => 'Cart - Products', 'description' => 'Shopping Cart(s) for TYPO3 - Products', 'category' => 'plugin', - 'version' => '6.0.1', + 'version' => '6.1.0', 'state' => 'stable', 'author' => 'Daniel Gohlke', 'author_email' => 'ext@extco.de',