georgringer/numbered-pagination 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

georgringer/numbered-pagination

Composer 安装命令:

composer require georgringer/numbered-pagination

包简介

Improved pagination for TYPO3

README 文档

README

Since TYPO3 10 a new pagination API is shipped which supersedes the pagination widget controller which is removed in version 11.0. Official documentation

This extension provides an improved pagination which can be used to paginate array items or query results from Extbase. The main advantage is that it reduces the amount of pages shown.

Example: Imagine 1000 records and 20 items per page which would lead to 50 links. Using the NumberedPagination, you will get something like < 1 2 ... 21 22 23 24 ... 100 >

Installation

Install the extension with composer require georgringer/numbered-pagination or by downloading it from extensions.typo3.org or the Extension Manager.

Usage

Just replace the usage of SimplePagination with \GeorgRinger\NumberedPagination\NumberedPagination and you are done. Set the 2nd argument to the maximum number of links which should be rendered.

$itemsPerPage = 10;
$maximumLinks = 15;
$currentPage = $this->request->hasArgument('currentPage') ? (int)$this->request->getArgument('currentPage') : 1;
$paginator = new \TYPO3\CMS\Extbase\Pagination\QueryResultPaginator($allItems, $currentPage, $itemsPerPage);
$pagination = new \GeorgRinger\NumberedPagination\NumberedPagination($paginator, $maximumLinks);
$this->view->assign('pagination', [
    'paginator' => $paginator,
    'pagination' => $pagination,
]);

Templating

<f:for each="{pagination.paginator.paginatedItems}" as="item" iteration="iterator">
    <f:render partial="Item" arguments="{item:item}" />
</f:for>
<f:render partial="Pagination" arguments="{pagination: pagination.pagination, paginator: pagination.paginator, actionName: 'listXYZ'}" />

Copy the pagination partial EXT:numbered_pagination/Resources/Private/Partials/Pagination.html to your extension or use it directly by providing the path mapping:

# Example for extension "fo"
plugin.tx_fo.view.partialRootPaths.4483 = EXT:numbered_pagination/Resources/Private/Partials/

The default paginator looks like this:

  • [1] 2 3 … next
  • 1 [2] 3 … next
  • prev … 2 [3] 4 … next
  • prev … 3 [4] 5
  • prev … 3 4 [5]

Here's three how-to's on how to achieve different, still common paginators:

Scenario 1

By uncommenting li.first and li.last and commenting out li.prev and li.next it looks like this:

  • [1] 2 3 … last
  • 1 [2] 3 … last
  • first 2 [3] 4 last
  • first … 3 [4] 5
  • first … 3 4 [5]

Scenario 1 (alternative)

By additionally changing their text to 1 and {pagination.lastPageNumber} it looks like this:

  • [1] 2 3 … 5
  • 1 [2] 3 … 5
  • 1 2 [3] 4 5
  • 1 … 3 [4] 5
  • 1 … 3 4 [5]

Scenario 3

By uncommenting li.first and li.last (and renaming them to |< and >|) and flipping their position with li.prev and li.next (and renaming them to < and >) it looks like this:

  • [1] 2 3 … > >|
  • 1 [2] 3 … > >|
  • |< < … 2 [3] 4 … > >|
  • |< < … 3 [4] 5
  • |< < … 3 4 [5]

Remark on 'dots'

In case the two properties {pagination.hasLessPages} and {pagination.hasMorePages} don't exactly suit the scenario you're trying to set up, think about doing your own calculations. Here's an example:

<!-- instead of {pagination.hasLessPages} which is 'displayRangeStart > 1' internally -->
<f:if condition="{pagination.displayRangeStart} > 2">
    <li>…</li>
</f:if>

<!-- instead of {pagination.hasMorePages} which is 'displayRangeEnd < lastPageNumber' internally -->
<f:if condition="{pagination.displayRangeEnd + 1} < {pagination.lastPageNumber}">
    <li>…</li>
</f:if>

georgringer/numbered-pagination 适用场景与选型建议

georgringer/numbered-pagination 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.45M 次下载、GitHub Stars 达 28, 最近一次更新时间为 2021 年 01 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「pagination」 「typo3」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 georgringer/numbered-pagination 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 georgringer/numbered-pagination 我们能提供哪些服务?
定制开发 / 二次开发

基于 georgringer/numbered-pagination 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.45M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 28
  • 点击次数: 9
  • 依赖项目数: 14
  • 推荐数: 6

GitHub 信息

  • Stars: 28
  • Watchers: 2
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2021-01-26