In some modules I want to make a different output of information depending on the name of the hook. How to write a working condition in the module tpl?
2 Answers
You can add a smarty variable with that information, eg. in the hook where you will render a tpl you could do this:
$this->context->smarty->assign('hook_origin', 'your-hook-name');
return $this->display(__FILE__, 'views/templates/hook/myTemplate.tpl');
Now in your tpl myTemplate.tpl
you can evaluate the source hook:
{if $hook_origin == 'your-hook-name'}
{* Your code for this hook here *}
{elseif $hook_origin == 'your-other-hook-name'}
{* Your code for this hook here *}
{else}
{* Your code for others *}
{/if}
-
Thank you... But.. There is a solution code only for tpl? I create a theme for addons. As far as I know, can't not edit php, otherwise they will not accept the theme. Mar 20, 2019 at 21:54
-
-
Help me grow me reputation, please. And I help you too. I wish take you pluse, but need 15 points for this. Mar 21, 2019 at 15:13
If you want to change the PHP file of a module then you need to override that module in your theme. And deactivate the default module of a Prestashop. By overriding the module according to your theme, you are having full control over the PHP and template file.