Download the PHP package tianhe1986/fatpagination without Composer
On this page you can find all versions of the php package tianhe1986/fatpagination. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download tianhe1986/fatpagination
More information about tianhe1986/fatpagination
Files in tianhe1986/fatpagination
Download tianhe1986/fatpagination
More information about tianhe1986/fatpagination
Files in tianhe1986/fatpagination
Vendor tianhe1986
Package fatpagination
Short Description A simple php pagination library
License MIT
Homepage https://github.com/tianhe1986/FatPagination
Package fatpagination
Short Description A simple php pagination library
License MIT
Homepage https://github.com/tianhe1986/FatPagination
Keywords phppagination
Please rate this library. Is it a good library?
Informations about the package fatpagination
安装
确保PHP版本在5.5以上。
推荐通过Composer进行安装
Composer的安装请参考官方配置。
安装好Composer后,在你的项目中创建一个 composer.json 文件:
然后在项目文件夹下执行:
之后添加autoloader:
分页处理
简单的用法示例如下:
则$urlHtml
对应如下html代码:
$divHtml
对应如下html代码:
默认情况下,会使用page
作为分页的参数,当前页码会加上class="active",当前页左右最多各展示3个数字页码。可以通过传入参数更改这些配置,具体的参数列表见下一小节。
传入参数
所有支持的参数列表如下:
参数名 | 说明 |
---|---|
pageParam | 分页的参数名,默认为 page |
url | 分页的url,不设置的话默认为当前url,会自动去除query_string中的分页参数部分 |
totalNum | 数据总条数 |
pageSize | 每页数据展示条数,默认为10 |
currentPage | 当前页码,默认为1 |
sidePageNum | 当前页码左右两边最多展示多少个数字页码。以设置为2举例, 当前页码为1,则展示 1 2 3,如果当前页码为2,则展示 1 2 3 4, 为3则展示 1 2 3 4 5 |
prevPageText | 上一页链接展示文本, 默认为“上一页” |
nextPageText | 下一页链接展示文本, 默认为“下一页” |
firstPageText | 首页链接展示文本, 默认为“首页” |
lastPageText | 末页链接展示文本, 默认为“末页” |
attrs | 数组,给标签附加的额外属性,具体参数见下表 |
所有attrs参数列表如下:
参数名 | 说明 |
---|---|
div | div标签附加属性,仅生成div列表时有效 |
ul | ul标签附加属性,仅生成ul列表时有效 |
a | 非当前数字页码a标签附加属性,仅div列表有效 |
li | 非当前数字页码li标签附加属性,仅ul列表有效 |
currentPage | 当前数字页码附加属性,div列表附加在a标签上,ul列表附加在li标签上。 默认会附加 class="active" |
prevPage | 上一页附加属性,div列表附加在a标签上,ul列表附加在li标签上 |
nextPage | 下一页附加属性,div列表附加在a标签上,ul列表附加在li标签上 |
firstPage | 首页附加属性,div列表附加在a标签上,ul列表附加在li标签上 |
lastPage | 末页附加属性,div列表附加在a标签上,ul列表附加在li标签上 |
以下是包含全部参数的ul列表生成示例:
将生成
div列表生成示例:
将生成
自行构造分页html
如果提供的参数依旧不能满足需要,可以按照如下方式,获取首/末页,上/下一页,以及数字页码,然后自行拼接html:
则最终$html
为:
All versions of fatpagination with dependencies
PHP Build Version
Package Version
Requires
php Version
>=5.5
The package tianhe1986/fatpagination contains the following files
Loading the files please wait ....