tasofen/pagination
Composer 安装命令:
composer require tasofen/pagination
包简介
Page navigation
README 文档
README
composer require tasofen/pagination
Constructor options
| Name | Type | Default | Description |
|---|---|---|---|
| showPages | Number | 11 | Count number links |
| url | String | '?page=%s' | URL |
| listTag | String | ul | Wrap all links |
| listClass | String | pagination | Class for wrap tag |
| itemWrap | String | li | Wrap item link |
| itemClass | String | page-item waves-effect | Class for wrap item tag |
| linkClass | String | page-link | Class for link |
| activeClass | String | active | Active class |
| first | Boolean | true | Show link to first page |
| last | Boolean | true | Show link to last page |
| prev | Boolean | true | Show link to prev page |
| next | Boolean | true | Show link to next page |
Methods
$pagination->getHtml($currentPate, $totalPage); $pagination->getJSON($currentPate, $totalPage); $pagination->getArray($currentPate, $totalPage);
Base usage
require 'vendor/autoload.php'; $pagination = new Tasofen\Pagination([ 'showPages' => 5 ]); echo $pagination->getHtml(7, 20); //currentPage, totalPage
Result:
<ul class="pagination"> <li class="page-item waves-effect"> <a href="?page=1" class="page-link"><<</a> </li> <li class="page-item waves-effect"> <a href="?page=6" class="page-link"><</a> </li> <li class="page-item waves-effect"> <a href="?page=5" class="page-link">5</a> </li> <li class="page-item waves-effect"> <a href="?page=6" class="page-link">6</a> </li> <li class="active page-item waves-effect"> <a href="?page=7" class="active page-link">7</a> </li> <li class="page-item waves-effect"> <a href="?page=8" class="page-link">8</a> </li> <li class="page-item waves-effect"> <a href="?page=9" class="page-link">9</a> </li> <li class="page-item waves-effect"> <a href="?page=8" class="page-link">></a> </li> <li class="page-item waves-effect"> <a href="?page=20" class="page-link">>></a> </li> </ul>
Example 1
$pagination = new Tasofen\Pagination([ 'showPages' => 5 ]); for($i=1;$i<=10; $i++) { echo '<div>'; echo $pagination->getHtml($i, 10); echo '</div>'; }
Result
Example 2
$pagination = new Tasofen\Pagination([ 'showPages' => 3 ]); $list = $pagination->getArray(7, 20); //currentPage, totalPage print_r($list);
Result
Array
(
[0] => Array
(
[url] => ?page=1
[text] => <<
[active] => false
)
[1] => Array
(
[url] => ?page=6
[text] => <
[active] => false
)
[2] => Array
(
[url] => ?page=6
[text] => 6
[active] => false
)
[3] => Array
(
[url] => ?page=7
[text] => 7
[active] => true
)
[4] => Array
(
[url] => ?page=8
[text] => 8
[active] => false
)
[5] => Array
(
[url] => ?page=8
[text] => >
[active] => false
)
[6] => Array
(
[url] => ?page=20
[text] => >>
[active] => false
)
)
tasofen/pagination 适用场景与选型建议
tasofen/pagination 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 11 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bootstrap」 「pagination」 「materializecss」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tasofen/pagination 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tasofen/pagination 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tasofen/pagination 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Bundle de Symfony creado por la Secretaría de Tecnologías para la Gestión del Ministerio de Gobierno y Reforma del Estado de la Provincia de Santa Fe
This is the Materialize extension for Yii framework 2.0. It encapsulates Materialize components and plugins in terms of Yii widgets, and thus makes using Materialize components/plugins in Yii applications extremely easy.
Views for the package MedicOneSystems Livewire Datatables with Bootstrap 4
Provides a Data Grid tables for your Symfony project.
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
Normalize an index range from user input
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-20

