From 9b0b2c4aa3d3e9d7278bf96b643fff6e4086d2c5 Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Mon, 27 Feb 2012 16:34:32 +0000 Subject: [PATCH] [-] FO : #PSFV-553 - Fix bugs with pager and ordering with some controllers git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13642 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/Link.php | 18 +++++++++++++----- classes/controller/FrontController.php | 3 ++- themes/default/product-sort.tpl | 24 ++++++++++++++---------- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/classes/Link.php b/classes/Link.php index c19aa0e89..2f487b02c 100644 --- a/classes/Link.php +++ b/classes/Link.php @@ -416,14 +416,22 @@ class LinkCore public function getPaginationLink($type, $id_object, $nb = false, $sort = false, $pagination = false, $array = false) { + // If no parameter $type, try to get it by using the controller name + if (!$type && !$id_object) + { + $method_name = 'get'.Dispatcher::getInstance()->getController().'Link'; + if (method_exists($this, $method_name) && isset($_GET['id_'.Dispatcher::getInstance()->getController()])) + { + $type = Dispatcher::getInstance()->getController(); + $id_object = $_GET['id_'.Dispatcher::getInstance()->getController()]; + } + } + if ($type && $id_object) $url = $this->{'get'.$type.'Link'}($id_object, null); else - { - $url = $this->url; - if (Configuration::get('PS_REWRITING_SETTINGS')) - $url = $this->getPageLink(basename($url)); - } + $url = $this->getPageLink(Context::getContext()->controller->php_self); + $vars = (!$array) ? '' : array(); $vars_nb = array('n', 'search_query'); $vars_sort = array('orderby', 'orderway'); diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php index 3298320e6..c73356ec1 100755 --- a/classes/controller/FrontController.php +++ b/classes/controller/FrontController.php @@ -320,7 +320,8 @@ class FrontControllerCore extends Controller 'vat_management' => (int)Configuration::get('VATNUMBER_MANAGEMENT'), 'opc' => (bool)Configuration::get('PS_ORDER_PROCESS_TYPE'), 'PS_CATALOG_MODE' => (bool)Configuration::get('PS_CATALOG_MODE') || !(bool)Group::getCurrent()->show_prices, - 'b2b_enable' => (bool)Configuration::get('PS_B2B_ENABLE') + 'b2b_enable' => (bool)Configuration::get('PS_B2B_ENABLE'), + 'request' => $link->getPaginationLink(false, false, false, true) )); // Deprecated diff --git a/themes/default/product-sort.tpl b/themes/default/product-sort.tpl index 2f17d0769..8333771b7 100644 --- a/themes/default/product-sort.tpl +++ b/themes/default/product-sort.tpl @@ -25,15 +25,19 @@ *} {if isset($orderby) AND isset($orderway)} - -{if isset($smarty.get.id_category) && $smarty.get.id_category} - {assign var='request' value=$link->getPaginationLink('category', $category, false, true)} -{elseif isset($smarty.get.id_manufacturer) && $smarty.get.id_manufacturer} - {assign var='request' value=$link->getPaginationLink('manufacturer', $manufacturer, false, true)} -{elseif isset($smarty.get.id_supplier) && $smarty.get.id_supplier} - {assign var='request' value=$link->getPaginationLink('supplier', $supplier, false, true)} -{else} - {assign var='request' value=$link->getPaginationLink(false, false, false, true)} + +{* On 1.5 the var request is setted on the front controller. The next lines assure the retrocompatibility with some modules *} +{if !isset($request)} + + {if isset($smarty.get.id_category) && $smarty.get.id_category} + {assign var='request' value=$link->getPaginationLink('category', $category, false, true)} + {elseif isset($smarty.get.id_manufacturer) && $smarty.get.id_manufacturer} + {assign var='request' value=$link->getPaginationLink('manufacturer', $manufacturer, false, true)} + {elseif isset($smarty.get.id_supplier) && $smarty.get.id_supplier} + {assign var='request' value=$link->getPaginationLink('supplier', $supplier, false, true)} + {else} + {assign var='request' value=$link->getPaginationLink(false, false, false, true)} + {/if} {/if}