2017-02-24 19 views
0

我想在Prestashop後臺創建一個簡單的頁面。我不需要任何ObjectModel。Prestashop:在Admincontroller中顯示簡單頁面(不包含ObjectModel)

我創建了一個新的管理員選項卡。我的問題是在AdminController。

您可以看到以下代碼:變量不會傳輸到模板文件。我不明白如何去做。

類AdminAzertyController擴展AdminController {

public function initContent() 
{ 

    parent::initContent(); 

    // Le template smarty 

    $tpl_path = _PS_MODULE_DIR_ .'paniersdegout/views/templates/admin/view.tpl'; 
    $tpl = $this->context->smarty->createTemplate($tpl_path, $this->context->smarty); 
    $content = $tpl->fetch();  
    $this->context->smarty->assign('content', $content); 

// Le passage de variable 
    $this->context->smarty->assign('test', 'test'); 


} 

}

+0

我想你是在將變量分配給該模板之前獲取模板內容的。 – Dhirender

+0

您應該在提取之前傳遞變量。祝你好運。 – PrestaAlba

回答

0

要渲染自定義控制器自定義第三方物流的文件,你可以使用Smarty的分配內容。

例如,如果您必須呈現自定義模塊的customtemplate.tpl文件。

public function initContent() { 

     parent::initContent(); 

     $content = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'custommodule/views/templates/admin/customtemplate.tpl'); 

     $this->context->smarty->assign(
       array(
        'content' => $this->content . $content, 
       ) 
     ); 
} 
相關問題