prestashop 1.7.6中的缺少$ template参数,当从钩子渲染时

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

我正在使用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

我已尝试删除缓存,重新安装模块等。

我显然缺少明显的东西。任何帮助表示赞赏。

php prestashop prestashop-1.7
1个回答
1
投票

[hookActionValidateOrder是一个动作挂钩,而不是显示挂钩,因此您无法显示模板。

您需要在要显示代码的位置签入模板,并显示哪些挂钩。

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