scandio/paginator-bundle

一个简单的用于 Symfony2 的分页包,无任何杂乱。

安装: 221

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 23

分支: 0

开放问题: 0

类型:symfony-bundle

dev-master 2014-02-23 22:43 UTC

This package is not auto-updated.

Last update: 2024-09-14 16:00:07 UTC


README

一个简单的用于 Symfony2 的分页包,无任何杂乱。

需求

  • Symfony2 >=2.1.0
  • Twig >=1.5 版本

安装

通过 composer.json 安装

...
"repositories": [
        {
            "type": "git",
            "url": "https://github.com/scandio/ScandioPaginatorBundle.git"
        }
    ],
...
 "require": {
        ...
        "scandio/paginator-bundle": "dev-master"
        ...
    },

如果你使用 deps 文件,请添加

[ScandioPaginatorBundle]
    git=http://github.com/scandio/ScandioPaginatorBundle.git
    target=bundles/Scandio/PaginatorBundle

或者如果你想克隆仓库

# Install Paginator
git clone git://github.com/scandio/ScandioPaginatorBundle.git vendor/bundles/Scandio/PaginatorBundle

使用方法

你必须构建自己的数据库函数!这不是一个 doctrine 查询分页器!请使用 KnpPaginatorBundle 来实现。

<?php
$em = $this->get('doctrine')->getEntityManager();
$paginator = $this->get('scandio.paginator');
$repository = $em->getRepository('...');
$page = $request->get('page', 1);
$limit = 10;

$attributes = $repository->getAll($page, $limit);
$maxCount = $repository->getAllCount();

// fill with data
$paginator->setLimit($limit);
$paginator->setPage($page);
$paginator->setList($attributes);
$paginator->setTotalCount($maxCount);

return array(
	'page' => $page,
	'attributes' => $paginator
);

查看

<ul>
{% for attribute in attributes %}
    <li>{{attribute}}</li>
{% endfor %}
</ul>

{# use pagination link here. Use "page" for pagination index number #}
{{ attributes.paginationBar('attributes_pagination') | raw }}

许可证

版权所有 (c) Scandio http://https://github.com/scandio/

本软件遵循 MIT 许可证。

特此授予任何获得本软件及其相关文档副本(以下简称“软件”)的人免费权利,以不受限制地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本,并允许向获得软件的人提供使用该软件的权利,前提是遵守以下条件

上述版权声明和本许可声明应包含在软件的副本或主要部分中。

本软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、适用于特定目的和非侵权性保证。在任何情况下,作者或版权所有者不应对任何索赔、损害或其他责任负责,无论该索赔、损害或其他责任是基于合同、侵权或其他原因,以及与软件或使用或操作软件相关的任何情况。