使用Prestashop 1.7从覆盖控制器设置模板

时间:2017-11-10 07:47:31

标签: php templates prestashop-1.7

我在Prestashop 1.7中对控制器进行了如下操作:

/override/controllers/front/MyAccountController.php

    class MyAccountController extends MyAccountControllerCore
    {


    /**
     * Assign template vars related to page content
     * @see FrontController::initContent()
     */
    public function initContent()
    {
        $this->context->smarty->assign([
            'logout_url' => $this->context->link->getPageLink('index', true, null, 'mylogout')
        ]);

        parent::initContent();
        $this->setTemplate("module:configurateur/views/templates/front/my-account.tpl");
    }
}

所以我试图在我的自定义模块中调用一个视图" configurateur"用这一行:

 $this->setTemplate("module:configurateur/views/templates/front/my-account.tpl");

此文件存在且位于正确的文件夹中(我认为):

\模块\ configurateur \视图\模板\前\ MY-account.tpl

当我尝试加载页面时,出现此错误:

  

找不到模块的模板:configurateur / views / templates / front / my-account.tpl   在文件类/ Smarty / TemplateFinder.php

的第68行

有人能说出我的错误吗?

1 个答案:

答案 0 :(得分:1)

语法“module:...”是only for ModuleFrontController objects,而不是FrontController:

在您的情况下,您应使用挂钩DisplayOverrideTemplate或将页面myaccount重定向到模块控制器。