我想限制分页框永远不变。假设已加载100个事件 - >显示3个事件/页面;并且分页框[1][2][3][4]....[40]
不会继续......
答案 0 :(得分:1)
在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
如果您需要更改滑动使用中的任何一个:
dL = np.diff(lon)
ix = np.argmax(dL<0)+1
L = lon[0:ix]
答案 1 :(得分:0)
我猜knp paginator会为你做这件事 但是如果没有你可以尝试修改上面的任何模板来做这样的事情:
设置控制变量
{% 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函数。
什么对你有用。