-
Notifications
You must be signed in to change notification settings - Fork 1
/
_pagination.twig
executable file
·51 lines (44 loc) · 1.43 KB
/
_pagination.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{% set link = pager.makelink() %}
{% if pager.totalpages > 1 %}
<style>
.pager li{
display: inline;
}
.pagination .buttons {
min-width: initial;
}
.pagination .active .button {
border-color: #82b440;
background-color: #82b440;
color: white;
}
</style>
</br>
<ul class="pagination buttons">
{# 'first' and 'prev' #}
{% if pager.current > 1 and class!="narrow" %}
<li><a class="button" href="{{link}}{{pager.current-1}}">‹ </a></li>
{% endif %}
{% if pager.current > surr+1 %}
<li><a class="button" href="{{link}}{{1}}">1</a></li>
{% endif %}
{# start with '..' if there are more than surr+1 before currentpage.. #}
{% if pager.current > surr+2 %}
<li class="disabled">...</li>
{% endif %}
{% for i in max(1, pager.current-surr)..min(pager.current+surr, pager.totalpages) %}
<li {% if i==pager.current %}class="current active"{%endif%}><a class="button" href="{{link}}{{i}}">{{i}}</a></li>
{% endfor %}
{# end with '..' if there are more than surr+1 after currentpage.. #}
{% if pager.current < (pager.totalpages - surr - 1) %}
<li class="disabled">...</li>
{% endif %}
{# 'next' and 'last' #}
{% if pager.current < pager.totalpages-surr %}
<li><a class="button" href="{{link}}{{pager.totalpages}}">{{pager.totalpages}}</a></li>
{% endif %}
{% if pager.current < pager.totalpages and class!="narrow" %}
<li><a class="button" href="{{link}}{{pager.current+1}}">›</a></li>
{% endif %}
</ul>
{% endif %}