承接 makscraft/pagination 相关项目开发

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

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

makscraft/pagination

最新稳定版本:1.0.0

Composer 安装命令:

composer require makscraft/pagination

包简介

Pagination manager for Symfony applications.

README 文档

README

Pagination manager for Symfony applications.

Generates list of links and parameters for SQL queries.

pagination

Installation

composer require makscraft/pagination

Example of use in controller or repository

use Makscraft\Pagination;

$total = ... ; //count your all needed items
$limit = 20; //items per page

$pagination = new Pagination($total, $limit);
$repository -> findBy([...], [...], $pagination -> getLimit(), $pagination -> getOffset());
  
//Returns array of links for html template.
$data = $pagination -> setPath('/catalog') -> getDisplayData();

Result links in $data will look like: '/catalog?page=3'.

You can pass the path with additional GET parameters if you want.

$pagination -> setPath('/catalog?sort=name&direction=asc');

For twig templates

Use package twig template or copy it into templates directory of your project. Inside the controller pass the pagination object into template.

return $this -> render('mypage.html.twig', [
    
    ...
    
    'pagination' => $pagination
]);

To use template from vendor directory add the path into twig config file.

# config/packages/twig.yaml    
paths:
    'vendor/makscraft/pagination/templates': 'pagination'

Next include the pagination template into your twig files.

{% include '@pagination/pagination.html.twig' %}

Also you can copy the template file into your templates directory and use it as you like.

Template file location: vendor/makscraft/pagination/templates/pagination.html.twig

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-30