forked from praswicaksono/html5up-striped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_mypager.twig
37 lines (32 loc) · 1.13 KB
/
_mypager.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
{% set link = pager.makelink() %}
{% if pager.totalpages > 1 %}
<div class="pagination {{class}}">
<div class="pages">
{# 'first' and 'prev' #}
{% if pager.current > 1 and class!="narrow" %}
<a href="{{link}}{{pager.current-1}}">‹ </a>
{% endif %}
{% if pager.current > surr+1 %}
<a href="{{link}}{{1}}">« 1</a>
{% endif %}
{# start with '..' if there are more than surr+1 before currentpage.. #}
{% if pager.current > surr+2 %}
<a href="#">...</a>
{% endif %}
{% for i in max(1, pager.current-surr)..min(pager.current+surr, pager.totalpages) %}
<a {% if i==pager.current %}class='active'{%endif%} href="{{link}}{{i}}">{{i}}</a>
{% endfor %}
{# end with '..' if there are more than surr+1 after currentpage.. #}
{% if pager.current < (pager.totalpages - surr - 1) %}
<a href="#">...</a>
{% endif %}
{# 'next' and 'last' #}
{% if pager.current < pager.totalpages-surr %}
<a href="{{link}}{{pager.totalpages}}">{{pager.totalpages}} » </a>
{% endif %}
{% if pager.current < pager.totalpages and class!="narrow" %}
<a href="{{link}}{{pager.current+1}}">›</a>
{% endif %}
</div>
</div>
{% endif %}