bootpress/pagination

创建可定制的分页和翻页链接。限制和偏移数组以及数据库查询。内置Bootstrap、Zurb Foundation、Semantic UI、Materialize和UIkit样式。

v1.0 2016-10-03 00:02 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:58:32 UTC


README

Packagist License MIT HHVM Tested PHP 7 Supported Build Status Code Climate Test Coverage

创建可定制的分页和翻页链接。限制和偏移数组以及数据库查询。内置Bootstrap、Zurb Foundation、Semantic UI、Materialize和UIkit样式。

安装

将以下内容添加到您的 composer.json 文件中。

{
    "require ": {
        "bootpress/pagination": "^1.0"
    }
}

示例用法

<?php

use BootPress\Pagination\Component as Paginator;

$pagination = new Paginator;

// Paginate an array
$records = range(1, 100);
if (!$pagination->set('page', 10, 'http://example.com')) {
    $pagination->total(count($records));
}
$display = array_slice($records, $pagination->offset, $pagination->length);
echo implode(',', $display); // 1,2,3,4,5,6,7,8,9,10

// Generate pagination links
echo $pagination->links();
/*
<ul class="pagination">
    <li class="active"><span>1</span></li>
    <li><a href="http://example.com?page=2of10">2</a></li>
    <li><a href="http://example.com?page=3of10">3</a></li>
    <li><a href="http://example.com?page=4of10">4</a></li>
    <li><a href="http://example.com?page=5of10">5</a></li>
    <li><a href="http://example.com?page=6of10">6</a></li>
    <li><a href="http://example.com?page=7of10">7</a></li>
    <li class="disabled"><span>&hellip;</span></li>
    <li><a href="http://example.com?page=10of10">10</a></li>
    <li><a href="http://example.com?page=2of10">&raquo;</a></li>
</ul>
*/

// And a pager for good measure
echo $pagination->pager();
/*
<ul class="pager">
    <li class="next"><a href="http://example.com?page=2of10">Next &raquo;</a></li>
</ul>
*/

许可证

MIT许可证(MIT)。请参阅许可证文件获取更多信息。