From 287574a743df4c45217dadff78bfe045bfa5b986 Mon Sep 17 00:00:00 2001 From: fSerny Date: Mon, 5 Dec 2011 15:49:56 +0000 Subject: [PATCH] [-] PROJECT : You can now execute hook in the tpl --- classes/Hook.php | 7 +++++++ config/smarty.config.inc.php | 7 +++++++ modules/carriercompare/config.xml | 4 ++-- modules/vatnumber/config.xml | 5 ++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/classes/Hook.php b/classes/Hook.php index 5f0c3cf3a..6af2a293d 100644 --- a/classes/Hook.php +++ b/classes/Hook.php @@ -175,10 +175,17 @@ class HookCore extends ObjectModel if ((!empty($id_module) && !Validate::isUnsignedId($id_module)) || !Validate::isHookName($hook_name)) die(Tools::displayError()); + if (!Hook::getIdByName($hook_name)) + return false; + self::preloadHookAlias(); $hook_name_retro = strtolower($hook_name); if (isset(self::$preloadHookAlias[$hook_name])) $hook_name = self::$preloadHookAlias[$hook_name]; + if (strtolower($hook_name) == strtolower($hook_name_retro)) + foreach (self::$preloadHookAlias as $alias => $new) + if (strtolower($hook_name_retro) == strtolower($new)) + $hook_name_retro = $alias; $live_edit = false; if (!isset($hookArgs['cookie']) || !$hookArgs['cookie']) diff --git a/config/smarty.config.inc.php b/config/smarty.config.inc.php index 5afbc94bd..d4408d92f 100644 --- a/config/smarty.config.inc.php +++ b/config/smarty.config.inc.php @@ -58,6 +58,7 @@ smartyRegisterFunction($smarty, 'function', 'm', 'smartyMaxWords'); // unused smartyRegisterFunction($smarty, 'function', 'p', 'smartyShowObject'); // Debug only smartyRegisterFunction($smarty, 'function', 'd', 'smartyDieObject'); // Debug only smartyRegisterFunction($smarty, 'function', 'l', 'smartyTranslate'); +smartyRegisterFunction($smarty, 'function', 'hook', 'smartyHook'); smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat')); smartyRegisterFunction($smarty, 'function', 'convertPrice', array('Product', 'convertPrice')); @@ -143,3 +144,9 @@ function smartyRegisterFunction($smarty, $type, $function, $params) return false; $smarty->registerPlugin($type, $function, $params); } + +function smartyHook($params, &$smarty) +{ + if (isset($params['h']) && !empty($params['h'])) + return Hook::exec($params['h']); +} diff --git a/modules/carriercompare/config.xml b/modules/carriercompare/config.xml index 013006548..966a249a4 100644 --- a/modules/carriercompare/config.xml +++ b/modules/carriercompare/config.xml @@ -2,11 +2,11 @@ carriercompare - + - 0 + 1 0 \ No newline at end of file diff --git a/modules/vatnumber/config.xml b/modules/vatnumber/config.xml index fee537cec..3c55c3cf2 100755 --- a/modules/vatnumber/config.xml +++ b/modules/vatnumber/config.xml @@ -7,7 +7,6 @@ 1 - 1 + 0 - - + \ No newline at end of file