forrest79/pagination
最新稳定版本:v0.3.0
Composer 安装命令:
composer require forrest79/pagination
包简介
Create pages list for pagination with logarithmic scale, neighbour pages or all pages.
README 文档
README
Create a page list for pagination with the logarithmic scale, neighbor pages or all pages.
Algorithms are copied from https://github.com/nikolassv/pagination.
Installation
The recommended way to install Forrest79/Pagination is through Composer:
composer require forrest79/pagination
How to use it
Just call PagesFactory:: with the page list you want:
$pages = Forrest79\Pagination\PagesFactory::all(100); $pages = Forrest79\Pagination\PagesFactory::neighbour(100, 1, 5); $pages = Forrest79\Pagination\PagesFactory::logarithmic(100, 10, 10);
You will get sorted array with integer pages numbers. For neighbor and logarithmic scale, there are also null values at place, where is broken pages series, for example: [1, 2, 3, null, 7, 8]. So you know where to print space. You can disable this behavior by settings parameter $addGaps to false.
Example with Nette
Simple using with default paginator:
class Paginator extends Nette\Utils\Paginator { public function pages(): array { if ($this->getPageCount() === null) { throw new InvalidArgumentException('We need page count set to generate pages list'); } return Forrest79\Pagination\PagesFactory::logarithmic($this->getPageCount(), $this->getPage(), 10); } }
And in latte:
<li n:foreach="$paginator->pages() as $page" n:class="$page === $paginator->getPage() ? active, $page === null ? disabled"> {if $page === null} .. {else} <a n:href="this, page => $page">{$page}</a> {/if} </li>
统计信息
- 总下载量: 1.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2019-03-10