-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpagination.tpl
85 lines (48 loc) · 1.86 KB
/
pagination.tpl
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
{{ if $gimme->current_list->count > $gimme->current_list->length }}
{{ $page=intval($gimme->url->get_parameter($gimme->current_list_id())) }}
{{ $list_id=$gimme->current_list_id() }}
{{$listLength=10}}
<nav class="pagination">
{{ unset_article }}
{{ if $gimme->current_list->has_previous_elements }}
<a href="{{ url options="previous_items" }}" class="arrow arrow_left" title="">{{'previous'|translate}}
</a>
{{/if}}
{{assign var="allPages" value=($gimme->current_list->count/$listLength)|ceil }}
{{assign var="currentPage" value=$page/$listLength}}
{{assign var="firstToShow" value=$currentPage-2}}
{{assign var="lastToShow" value=$currentPage+5}}
{{if $firstToShow < 1 }}
{{assign var="firstToShow" value=1}}
{{assign var="lastToShow" value=$lastToShow+3}}
{{/if}}
{{if $lastToShow > $allPages }}
{{assign var="lastToShow" value=$allPages+1}}
{{/if}}
{{if $lastToShow-$firstToShow>0}}
<div class="numbers">
<ul>
{{if $firstToShow>1}}
<li class="firstlast"><a href="{{ url options="section" }}">1</a></li>
<li class="firstlast">...</li>
{{/if}}
{{for $foo=$firstToShow to $lastToShow}}
{{if $foo-1==$currentPage}}
<li class="current"><a>{{ $foo }}</a></li>
{{else}}
<li><a href="{{ url options="section" }}?{{$list_id}}={{ ($foo-1)*$listLength }}">
{{ $foo }} </a></li>
{{/if}}
{{/for}}
{{if $lastToShow-1<$allPages}}
<li class="firstlast">...</li>
<li class="firstlast"><a href="{{ url options="section" }}?{{$list_id}}={{ ($allPages-1)*$listLength }}">{{$allPages}}</a></li>
{{/if}}
</ul>
</div>
{{/if}}
{{ if $gimme->current_list->has_next_elements }}
<a href="{{ url options="next_items" }}" class="arrow arrow_right" title="">{{'next'|translate}}</a>
{{ /if }}
</nav>
{{ /if }}