forked from nextras/datagrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path@bootstrap3.extended-pagination.datagrid.latte
39 lines (37 loc) · 1.23 KB
/
@bootstrap3.extended-pagination.datagrid.latte
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
{redefine pagination}
<?php
$page = $paginator->getPage();
if ($paginator->pageCount < 2) {
$steps = array($page);
} else {
$arr = range(max($paginator->firstPage, $page - 3), min($paginator->lastPage, $page + 3));
$count = 4;
$quotient = ($paginator->pageCount - 1) / $count;
for ($i = 0; $i <= $count; $i++) {
$arr[] = round($quotient * $i) + $paginator->firstPage;
}
sort($arr);
$steps = array_values(array_unique($arr));
}
?>
<ul class="pagination">
{if $paginator->isFirst()}
<li class="disabled"><a>« {$control->translate(Previous)}</a></li>
{else}
<li><a href="{link paginate!, 'page' => $paginator->page - 1}" rel="prev" class="ajax">« {$control->translate(Previous)}</a><li>
{/if}
{foreach $steps as $step}
{if $step == $paginator->page}
<li class="active"><a href="">{$step}</a></li>
{else}
<li><a href="{link paginate!, 'page' => $step}" class="ajax">{$step}</a></li>
{/if}
{if $iterator->nextValue > $step + 1}<li class="disabled"><a>…</a></li>{/if}
{/foreach}
{if $paginator->isLast()}
<li class="disabled"><a >{$control->translate(Next)} »</a></li>
{else}
<li><a href="{link paginate!, 'page' => $paginator->page + 1}" rel="next" class="ajax">{$control->translate(Next)} »</a></li>
{/if}
</ul>
{/redefine}