Prestashop 仅在某些页面上加载 tpl 文件

Prestashop loading tpl file on certain pages only

我想知道如何让我的模块仅在特定的管理面板页面上加载它的 tpl 文件。

在可以找到客户地址字段的页面上更精确。

我已经有了钩子:

    public function hookDisplayBackOfficeFooter()
{
    return $this-> addExtraField();
}

但问题是,它在每个页面上运行,这不是最佳做法,因此我需要进行某种评估。

好的,这是问题的解决方案。

我正在检查 url,如果里面有 'updateaddress',那么我来对地方了。

    public function hookDisplayBackOfficeFooter()
{
    if(strpos($_SERVER['REQUEST_URI'], 'updateaddress') !== false){
        return $this-> addExtraField();
    }

}

要根据页面条件呈现您的字段,请使用以下代码:

public function hookDisplayBackOfficeFooter()
{
     if ($this->context->controller == 'updateaddress') { // Your controller name
         return $this-> addExtraField();
     }  
}