在某些模块中,我希望根据钩子的名称生成不同的信息输出。如何在tpl模块中编写工作条件?
发布于 2019-03-21 05:35:03
你可以用这些信息添加一个聪明的变量,例如。在您将呈现tpl的钩子中,您可以这样做:
$this->context->smarty->assign('hook_origin', 'your-hook-name');
return $this->display(__FILE__, 'views/templates/hook/myTemplate.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}https://stackoverflow.com/questions/55270283
复制相似问题