PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 27, 2022

[FIXED] How to make different tpl depending on the name of the hook for module?

 October 27, 2022     prestashop, prestashop-1.7, smarty     No comments   

Issue

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?


Solution

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}


Answered By - Rolige
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing