2017-02-27 45 views
0

我想知道如何讓我的模塊只在特定的管理面板頁面上加載它的tpl文件。Prestashop僅在某些頁面上加載tpl文件

更準確地說,在可以定位客戶地址字段的頁面上。

我已經鉤:

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

但問題是,它運行的每一個頁面,這是不是最好的實踐,因此,我需要某種評價到位。

回答

2

爲了使您的領域基於網頁的條件,使用下面的代碼:

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

謝謝你,這是一個更復雜的解決方案! – Gregion

0

好的,這裏是解決問題的方法。

我在檢查網址,如果它裏面有'updateaddress',那麼我在正確的地方。

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

} 
相關問題