如何根据模块挂钩的名称制作不同的tpl?

问题描述 投票:0回答:2

在某些模块中,我想根据钩子的名称进行不同的信息输出。如何在模块tpl中编写工作条件?

prestashop smarty prestashop-1.7
2个回答
0
投票

您可以添加带有该信息的smarty变量,例如。在你将渲染tpl的钩子中你可以这样做:

$this->context->smarty->assign('hook_origin', 'your-hook-name');
return $this->display(__FILE__, 'views/templates/hook/myTemplate.tpl');

现在在你的tpl myTemplate.tpl中你可以评估源钩子:

{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}

0
投票

如果要更改模块的PHP文件,则需要在主题中覆盖该模块。并停用Prestashop的默认模块。通过根据主题覆盖模块,您可以完全控制PHP和模板文件。

© www.soinside.com 2019 - 2024. All rights reserved.