[-] MO : #PSFV-531 - Fix bug on the module Loyalty with pagination links
This commit is contained in:
@@ -38,6 +38,9 @@ class LoyaltyDefaultModuleFrontController extends ModuleFrontController
|
||||
|
||||
include_once($this->module->getLocalPath().'LoyaltyModule.php');
|
||||
include_once($this->module->getLocalPath().'LoyaltyStateModule.php');
|
||||
|
||||
// Declare smarty function to render pagination link
|
||||
smartyRegisterFunction($this->context->smarty, 'function', 'summarypaginationlink', array('LoyaltyDefaultModuleFrontController', 'getSummaryPaginationLink'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,6 +130,35 @@ class LoyaltyDefaultModuleFrontController extends ModuleFrontController
|
||||
$this->assignSummaryExecution();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render pagination link for summary
|
||||
*
|
||||
* @param (array) $params Array with to parameters p (for page number) and n (for nb of items per page)
|
||||
* @return string link
|
||||
*/
|
||||
public static function getSummaryPaginationLink($params, &$smarty)
|
||||
{
|
||||
if (!isset($params['p']))
|
||||
$p = 1;
|
||||
else
|
||||
$p = $params['p'];
|
||||
|
||||
if (!isset($params['n']))
|
||||
$n = 10;
|
||||
else
|
||||
$n = $params['n'];
|
||||
|
||||
return Context::getContext()->link->getModuleLink(
|
||||
'loyalty',
|
||||
'default',
|
||||
array(
|
||||
'process' => 'summary',
|
||||
'p' => $p,
|
||||
'n' => $n,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign summary template
|
||||
*/
|
||||
@@ -138,6 +170,7 @@ class LoyaltyDefaultModuleFrontController extends ModuleFrontController
|
||||
$this->context->smarty->assign(array(
|
||||
'orders' => $orders,
|
||||
'displayorders' => $displayorders,
|
||||
'this' => $this,
|
||||
'pagination_link' => $this->context->link->getModuleLink('loyalty', 'default'),
|
||||
'totalPoints' => (int)$customerPoints,
|
||||
'voucher' => LoyaltyModule::getVoucherValue($customerPoints, (int)($this->context->cookie->id_currency)),
|
||||
|
||||
@@ -69,13 +69,13 @@
|
||||
<ul class="pagination">
|
||||
{if $page != 1}
|
||||
{assign var='p_previous' value=$page-1}
|
||||
<li id="pagination_previous"><a href="{$pagination_link}?p={$p_previous}&n={$nbpagination}">
|
||||
<li id="pagination_previous"><a href="{summarypaginationlink p=$p_previous n=$nbpagination}">
|
||||
« {l s='Previous' mod='loyalty'}</a></li>
|
||||
{else}
|
||||
<li id="pagination_previous" class="disabled"><span>« {l s='Previous' mod='loyalty'}</span></li>
|
||||
{/if}
|
||||
{if $page > 2}
|
||||
<li><a href="{$pagination_link}?p=1&n={$nbpagination}">1</a></li>
|
||||
<li><a href="{summarypaginationlink p='1' n=$nbpagination}">1</a></li>
|
||||
{if $page > 3}
|
||||
<li class="truncate">...</li>
|
||||
{/if}
|
||||
@@ -84,18 +84,18 @@
|
||||
{if $page == $smarty.section.pagination.index}
|
||||
<li class="current"><span>{$page|escape:'htmlall':'UTF-8'}</span></li>
|
||||
{elseif $smarty.section.pagination.index > 0 && $orders|@count+$nbpagination > ($smarty.section.pagination.index)*($nbpagination)}
|
||||
<li><a href="{$pagination_link}?p={$smarty.section.pagination.index}&n={$nbpagination}">{$smarty.section.pagination.index|escape:'htmlall':'UTF-8'}</a></li>
|
||||
<li><a href="{summarypaginationlink p=$smarty.section.pagination.index n=$nbpagination}">{$smarty.section.pagination.index|escape:'htmlall':'UTF-8'}</a></li>
|
||||
{/if}
|
||||
{/section}
|
||||
{if $max_page-$page > 1}
|
||||
{if $max_page-$page > 2}
|
||||
<li class="truncate">...</li>
|
||||
{/if}
|
||||
<li><a href="{$pagination_link}?p={$max_page}&n={$nbpagination}">{$max_page}</a></li>
|
||||
<li><a href="{summarypaginationlink p=$max_page n=$nbpagination}">{$max_page}</a></li>
|
||||
{/if}
|
||||
{if $orders|@count > $page * $nbpagination}
|
||||
{assign var='p_next' value=$page+1}
|
||||
<li id="pagination_next"><a href="{$pagination_link}?p={$p_next}&n={$nbpagination}">{l s='Next' mod='loyalty'} »</a></li>
|
||||
<li id="pagination_next"><a href="{summarypaginationlink p=$p_next n=$nbpagination}">{l s='Next' mod='loyalty'} »</a></li>
|
||||
{else}
|
||||
<li id="pagination_next" class="disabled"><span>{l s='Next' mod='loyalty'} »</span></li>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user