Customising the layout of Pagerfanta pagination with a custom template(使用自定义模板自定义 Pagerfanta 分页的布局)
问题描述
I have Pagerfanta installed and working, however I am having difficulty in customising the layout. I read on Github that I need to pass through my_template
, however I am unsure where this should be configured and what specificially this refers to.
Custom template
If you want to use a custom template, add another argument
<div class="pagerfanta">
{{ pagerfanta(my_pager, 'my_template') }}
</div>
Ideally I would like to have my own Twig template that I can modify, however I don’t know if Pagerfanta supports this. Is it all done in PHP?
I don't think it supports Twig templates but for sure you can write your custom Template
class to render the pagination however you want.
Let's say in your AppBundle, you will need to create MyCustomTemplate
class which should extend PagerfantaViewTemplateDefaultTemplate:
<?php
namespace AcmeAppBundleTemplate;
use PagerfantaViewTemplateDefaultTemplate;
class MyCustomTemplate extends DefaultTemplate
{
// override whatever you need here ...
}
then register it in your services.yml file together with the view service:
services:
acme_app.template.my_template:
class: AcmeAppBundleTemplateMyCustomTemplate
pagerfanta.view.my_template:
class: PagerfantaViewDefaultView
public: false
arguments:
- "@acme_app.template.my_template"
tags: [{ name: pagerfanta.view, alias: my_template }]
then in your Twig templates you will be able to use:
{{ pagerfanta(my_pager, 'my_template') }}
which will result in displaying your custom pagination template.
这篇关于使用自定义模板自定义 Pagerfanta 分页的布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用自定义模板自定义 Pagerfanta 分页的布局
基础教程推荐
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01