Amazzing Posted April 19, 2014 Share Posted April 19, 2014 There is a very nice and handy way to add new hooks to Prestashop 1.5 templates: {hook h='nameOfTheHook'} But how can we check whether this hook is used or not? I need something like: {if $nameOfTheHook}{hook h='nameOfTheHook'}{/if} or {if !empty($nameOfTheHook)} {hook h='nameOfTheHook'} {else} Is that possible at all? Link to comment Share on other sites More sharing options...
vekia Posted April 19, 2014 Share Posted April 19, 2014 But how can we check whether this hook is used or not? what you exactly mean by that? something like: if there is any module attached to this hook { display something } ? Link to comment Share on other sites More sharing options...
Amazzing Posted April 19, 2014 Author Share Posted April 19, 2014 (edited) what you exactly mean by that? something like: if there is any module attached to this hook { display something } ? almost like that: if there is any module attached to this hook { display hook } else{ display something else } Edited April 19, 2014 by Amazzing (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted April 19, 2014 Share Posted April 19, 2014 should be enough to use this: {if Hook::getModulesFromHook(Hook::getIdByName("MyHook")) != null} {Hook::exec("MyHook")} {else} do something else {/if} Link to comment Share on other sites More sharing options...
Amazzing Posted April 21, 2014 Author Share Posted April 21, 2014 should be enough to use this: {if Hook::getModulesFromHook(Hook::getIdByName("MyHook")) != null} {Hook::exec("MyHook")} {else} do something else {/if} Thanks for your reply, but it doesn't alway work the way I need. I have only one module using that hook. No matter, whether this module is enabled or disabled, Hook::getModulesFromHook(Hook::getIdByName("MyHook")) != null always returns true. However I found another way to check whether this hook is used or not. And it works just the way I need: {assign var='nameOfTheHook' value={hook h='nameOfTheHook'[spam-filter] {if $nameOfTheHook} {$nameOfTheHook} {else} smth else {/if} 2 Link to comment Share on other sites More sharing options...
vekia Posted April 21, 2014 Share Posted April 21, 2014 ohh thanks i was confused due to this: if there is any module attached to this hook { display something } thank you for sharing solution :-) Link to comment Share on other sites More sharing options...
thepan Posted July 9, 2015 Share Posted July 9, 2015 Hey guys Is there a way to get this done {if $nameOfTheHook} {$nameOfTheHook} {else} smth else {/if} without {assign var='nameOfTheHook' value={hook h='nameOfTheHook'[spam-filter] Can we not check directly if the hook has anything assigned to? Link to comment Share on other sites More sharing options...
gonebdg - webindoshop.com Posted July 11, 2015 Share Posted July 11, 2015 You might be able to do something like this {if {hook h="nameOfTheHook"[spam-filter] {hook h="nameOfTheHook"} {else} {* nameOfTheHook is not available ... do something else here *} {/if} 1 Link to comment Share on other sites More sharing options...
Darius1990 Posted January 29, 2019 Share Posted January 29, 2019 On 7/11/2015 at 10:30 AM, gonebdg - webindoshop.com said: You might be able to do something like this {if {hook h="nameOfTheHook"[spam-filter] {hook h="nameOfTheHook"} {else} {* nameOfTheHook is not available ... do something else here *} {/if} Not sure why need [spam-filter] but work as charm! p.s. need } in the end of {if {hook h="nameOfTheHook"[spam-filter] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now