0

我想永远限制分页框。假设加载了 100 个事件 -> 每页显示 3 个事件;这样分页框[1][2][3][4]....[40]就不会继续了……

仅供参考:截图

4

2 回答 2

1

config.yml添加这个:

knp_paginator:
   page_range: 5 # number of links showed in the pagination menu (e.g: you have 10 pages, a page_range of 3, on the 5th page you'll see links to page 4, 5, 6)

如果您需要更改滑动,请使用以下任何一种:

template:                                        
    pagination: '@KnpPaginator/Pagination/sliding.html.twig'

@KnpPaginator/Pagination/sliding.html.twig (by default)
@KnpPaginator/Pagination/twitter_bootstrap_v3_pagination.html.twig
@KnpPaginator/Pagination/twitter_bootstrap_pagination.html.twig
@KnpPaginator/Pagination/foundation_v5_pagination.html.twig
于 2017-10-31T18:28:15.907 回答
0

我猜 knp 分页器会为您执行此操作,但如果没有,您可以尝试修改上面的任何模板以执行以下操作:

设置控制变量

{% if pageCount > maxNumberOfBoxes %}
        {% set breakpointAdded=true %}
{% endif %}

然后找到看起来像这样的循环

{% for page in pagesInRange %}
            {% if page != current %}
                <span class="page">
                <a href="{{ path(route, query|merge({(pageParameterName): page})) }}">{{ page }}</a>
            </span>
            {% else %}
                <span class="current">{{ page }}</span>
            {% endif %}

        {% endfor %}

并用这样的东西替换它(当然用你自己的逻辑)

{% for i in range(0,pageCount) %}
                {% if i > xBreakpoint and i < yBreakpoint and breakpointAdded == false %}
                    <span class="dots">...</span>
                    {% set breakpointAdded = true %}
                {% else %}
                    {% if page != current %}
                        <span class="page">
                            <a href="{{ path(route, query|merge({(pageParameterName): page})) }}">{{ page }}</a>
                       </span>
                    {% else %}
                        <span class="current">{{ page }}</span>
                    {% endif %}
                {% endif %}
            {% endfor %}

如果其中任何一项有效,您可以尝试从 SlidingPagination 类修改 getPaginationData 函数。

什么对你有用。

于 2017-11-01T13:15:29.380 回答