0

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 2

1

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}
3
  • 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
  • That’s no posible.
    – Rolige
    Mar 21, 2019 at 15:00
  • 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
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.