承接 forrest79/pagination 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

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

Latest Stable Version Monthly Downloads License Build

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2019-03-10