我正在使用Prestashop 1.7.6.4。我想在一个钩子中渲染一个模板。我正在通过以下代码进行此操作:
class MyModuleName extends PaymentModule
{
public function hookActionValidateOrder($params)
{
/**
* Verify if this module is enabled
*/
if (!$this->active) {
return;
}
if (Configuration::get('inline')) {
$this->context->smarty->assign([
'module' => $order->module
]);
return $this->display(__FILE__,
'views/templates/hook/displayStatusOrder.tpl');
}
// more code goes here
}
}
请注意,我也尝试过使用
return $this->fetch('module:myModule/views/templates/hook/displayStatusOrder.tpl');
结果相同。
但是我遇到以下错误:
(1/1) SmartyException
0():Missing '$template' parameter
我绝对确定我的模板存在。并且它具有正确的名称。
我的文件夹结构如下:
myModuleName
views
templates
hook
displayStatusOrder.tpl
我已尝试删除缓存,重新安装模块等。
我显然缺少明显的东西。任何帮助表示赞赏。
[hookActionValidateOrder
是一个动作挂钩,而不是显示挂钩,因此您无法显示模板。
您需要在要显示代码的位置签入模板,并显示哪些挂钩。