refactor paginator, introducing new variable $PREV, $NEXT and $END. By
default, 10 pages are display. you can use numPage for managing how many page are display
This commit is contained in:
@@ -241,7 +241,7 @@ class TheliaLoop extends AbstractSmartyPlugin
|
||||
|
||||
// Find pagination
|
||||
$pagination = self::getPagination($loopName);
|
||||
if ($pagination === null) { // loop gas no result
|
||||
if ($pagination === null) { // loop has no result
|
||||
|
||||
return '';
|
||||
}
|
||||
@@ -250,17 +250,33 @@ class TheliaLoop extends AbstractSmartyPlugin
|
||||
return '';
|
||||
}
|
||||
|
||||
$nbPage = $this->getParam($params, 'numPage', 10);
|
||||
$maxPage = $pagination->getLastPage();
|
||||
|
||||
|
||||
if ($content === null) {
|
||||
$page = 1;
|
||||
$page = $pagination->getPage();
|
||||
if($maxPage > ($page + $nbPage)) {
|
||||
$end = $page + $nbPage;
|
||||
} else {
|
||||
$end = $maxPage;
|
||||
}
|
||||
$template->assign('PREV', $page > 1 ? $page-1: $page);
|
||||
$template->assign('NEXT', $page < $maxPage ? $page+1 : $maxPage);
|
||||
$template->assign('END', $end);
|
||||
$template->assign('LAST', $pagination->getLastPage());
|
||||
|
||||
} else {
|
||||
$page = $template->getTemplateVars('PAGE');
|
||||
$page++;
|
||||
}
|
||||
|
||||
if ($page <= $pagination->getLastPage()) {
|
||||
|
||||
|
||||
if ($page <= $template->getTemplateVars('END')) {
|
||||
$template->assign('PAGE', $page);
|
||||
$template->assign('CURRENT', $pagination->getPage());
|
||||
$template->assign('LAST', $pagination->getLastPage());
|
||||
|
||||
|
||||
$repeat = true;
|
||||
}
|
||||
|
||||
@@ -182,13 +182,15 @@
|
||||
|
||||
<div class="text-center">
|
||||
<ul class="pagination pagination-centered">
|
||||
{if $page != 1}
|
||||
<li><a href="{url path="/admin/customers" page="1"}">«</a></li>
|
||||
{else}
|
||||
<li class="disabled"><a href="#">«</a></li>
|
||||
|
||||
{if $page != 1}
|
||||
<li><a href="{url path="/admin/customers" page="1"}">«</a></li>
|
||||
{/if}
|
||||
{pageloop rel="customer_list" numPage="20"}
|
||||
{if $PAGE == $CURRENT && $PAGE > 2}
|
||||
<li><a href="{url path="/admin/customers" page=$PREV}">‹</a></li>
|
||||
{/if}
|
||||
|
||||
{pageloop rel="customer_list"}
|
||||
{if $PAGE != $CURRENT}
|
||||
<li><a href="{url path="/admin/customers" page="{$PAGE}"}">{$PAGE}</a></li>
|
||||
|
||||
@@ -196,12 +198,12 @@
|
||||
<li class="active"><a href="#">{$PAGE}</a></li>
|
||||
{/if}
|
||||
|
||||
|
||||
{if $PAGE == $END && $PAGE < $LAST}
|
||||
<li><a href="{url path="/admin/customers" page=$NEXT}">›</a></li>
|
||||
{/if}
|
||||
{/pageloop}
|
||||
{if $PAGE == $LAST && $LAST != $CURRENT}
|
||||
<li><a href="{url path="/admin/customers" page="$PAGE"}">»</a></li>
|
||||
{else}
|
||||
<li class="disabled"><a href="#">»</a></li>
|
||||
{if $LAST > $CURRENT}
|
||||
<li><a href="{url path="/admin/customers" page="$LAST"}">»</a></li>
|
||||
{/if}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
{pageloop rel="product_list"}
|
||||
<li{if $PAGE eq $CURRENT} class="active"{/if}><a href="{url path={navigate to="current"} page=$PAGE }"> {$PAGE} </a></li>
|
||||
{if $PAGE eq $LAST}
|
||||
<li{if $CURRENT eq $LAST} class="disabled"{/if}><a href="{url path={navigate to="current"} page={$CURRENT+1} }" title="{intl l="Next"}" class="next"><i class="icon-next"></i></a></li>
|
||||
<li{if $CURRENT eq $LAST} class="disabled"{/if}><a href="{url path={navigate to="current"} page={$NEXT} }" title="{intl l="Next"}" class="next"><i class="icon-next"></i></a></li>
|
||||
{/if}
|
||||
{/pageloop}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user