From 229e12414b76dd04356de4292cd5ffc2db80952d Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Fri, 17 Feb 2012 14:49:29 +0000 Subject: [PATCH] [-] MO : #PSFV-531 - Fix bug on the module Loyalty with pagination links --- modules/loyalty/controllers/front/default.php | 33 +++++++++++++++++++ .../loyalty/views/templates/front/loyalty.tpl | 10 +++--- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/modules/loyalty/controllers/front/default.php b/modules/loyalty/controllers/front/default.php index 6319dec46..bd354a7ef 100644 --- a/modules/loyalty/controllers/front/default.php +++ b/modules/loyalty/controllers/front/default.php @@ -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)), diff --git a/modules/loyalty/views/templates/front/loyalty.tpl b/modules/loyalty/views/templates/front/loyalty.tpl index b86aa7240..3034ca9d0 100644 --- a/modules/loyalty/views/templates/front/loyalty.tpl +++ b/modules/loyalty/views/templates/front/loyalty.tpl @@ -69,13 +69,13 @@