abraovic / php-paginator
简单的适用于 Symfony2.8+ 的 PHP 分页器
v0.1
2019-05-23 11:08 UTC
Requires
- php: >=5.3
This package is auto-updated.
Last update: 2024-09-23 22:26:46 UTC
README
安装
推荐的安装方法是使用 Packagist 和 Composer。运行以下命令安装该包并将其添加到项目中的 composer.json
composer require abraovic/php-paginator
如何使用
将新的twig模板路径添加到 app/config/config.yml
# Twig Configuration twig: ... paths: '%kernel.root_dir%/../vendor/abraovic/php-paginator/src/template': 'abraovic_paginate'
在你的控制器中
use abraovic\phpPaginator\Paginate; class ... { function ... { return $this->render( 'some.html.twig', [ ..., 'pagination' => Paginate::data( $page, // current page $limit, // max limit per page $total, // total number of items $this->get('router')->generate('_route_name', array(), true) // route link - replace _route_name with proper name ) ] ); } }
在你的twig模板中
{{ include('@abraovic_paginate/_paginate.html.twig') }}
如果已安装 翻译包,您可以通过在应用的messages.yaml中添加键来翻译“第一”和“最后一页”标签,如下所示
First: [first in some other language] Last: [last in some other language]
贡献
欢迎贡献!请阅读 贡献指南 以获取详细信息。
版权和许可
abraovic/php-paginator 库版权所有 © Ante Braovic,许可协议为 MIT 许可证。