evheniy/simple-pagination-bundle

SimplePaginationBundle 提供了在您的应用程序中使用简单分页的能力。

安装次数: 12,658

依赖者: 1

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 0

公开问题: 0

类型:symfony-bundle

1.6 2015-04-19 09:00 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:38:28 UTC


README

knpbundles.com

Latest Stable Version Total Downloads Latest Unstable Version License

Scrutinizer Code Quality Build Status

Build Status

此包为您的 Symfony2 应用程序提供使用简单分页的能力。

安装

SimplePaginationBundle

$ composer require evheniy/simple-pagination-bundle "1.*"

Or add to composer.json

"evheniy/simple-pagination-bundle": "1.*"

AppKernel

    public function registerBundles()
        {
            $bundles = array(
                ...
                new Evheniy\SimplePaginationBundle\SimplePaginationBundle(),
            );
            ...

控制器

$pagination = $this->container->get('pagination');
$pageParameter = 'page';
$page = $request->get($pageParameter, 1);//page number
$size = $request->get('size', 10);//items per page
$range = 10;//navigation links on page 

return $this->render(
            'AppBundle:Default:index.html.twig',
            array(
                ...
                'pagination'  => $pagination->paginate(
                    $request->get('_route'),
                    $resultsCount,
                    $page,
                    $size,
                    $range,
                    $request->query->all(),
                    $pageParameter
                )
            )
        );

Twitter Bootstrap 的布局 Twitter Bootstrap

{% include "SimplePaginationBundle::pagination.bootstrap.html.twig" %}

或者简单

{% include "SimplePaginationBundle::pagination.html.twig" %}

样式,例如这样

<style>
.pagination {
    text-align: center;
}
.pagination span a {
    display: inline-block;
    padding: 4px 8px;
    margin: 3px;
    font-size: 12px;
    font-weight: normal;
    line-height: 1.42857143;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    border: 1px solid transparent;
    border-radius: 4px;
    color: #333;
    background-color: #fff;
    border-color: #ccc;
}
.pagination span a:hover {
    color: #333;
    text-decoration: none;
}
.pagination span a:active {
    outline: thin dotted;
    outline: 5px auto -webkit-focus-ring-color;
    outline-offset: -2px;
}
.pagination span.current {
    display: inline-block;
    padding: 4px 8px;
    margin-bottom: 0;
    font-size: 14px;
    font-weight: bold;
    line-height: 1.42857143;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    background-image: none;
    border: 1px solid transparent;
    border-radius: 4px;
    color: #333;
    background-color: #fff;
    border-color: #ccc;
}
</style>

许可证

此包受 MIT 许可证的约束。

俄语文档

演示