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

Php 仅在某些页面上加载tpl文件,php,model-view-controller,smarty,prestashop,Php,Model View Controller,Smarty,Prestashop,我想知道如何让我的模块只在特定的管理面板页面上加载它的tpl文件 更准确地说,在可以找到客户地址字段的页面上 我已经有钩子了: public function hookDisplayBackOfficeFooter() { return $this-> addExtraField(); } 但问题是,它在每一页上运行,这不是最佳实践,因此我需要进行某种评估。好的,这里有一个解决问题的方法 我正在检查url,如果其中有“updateaddress”,那么我就在正确的位置

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

更准确地说,在可以找到客户地址字段的页面上

我已经有钩子了:

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

但问题是,它在每一页上运行,这不是最佳实践,因此我需要进行某种评估。

好的,这里有一个解决问题的方法

我正在检查url,如果其中有“updateaddress”,那么我就在正确的位置

    public function hookDisplayBackOfficeFooter()
{
    if(strpos($_SERVER['REQUEST_URI'], 'updateaddress') !== false){
        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();
     }  
}

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

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

谢谢,这是一个更复杂的解决方案!谢谢,这是一个更复杂的解决方案!