2017-05-29 74 views
0

我使用PS 1.6.1.1,我想覆蓋MyAccountController在我的tpl文件中添加新的var。覆蓋MyAccountController Prestashop

創建我的override/controllers/front/MyAccountController與文件:

class MyAccountControllerCore extends FrontController 
public function initContent() 
{   
    $smarty = new Smarty; 
    $smarty->assign('firstname', 'Doug'); 

    $this->setTemplate(_PS_THEME_DIR_.'my-account.tpl'); 
} 

}

當我在TPL文件中調用<span>{$firstname}</span>,無法正常工作。

我刪除cache/class_index.php

任何想法?

謝謝!

回答

0

嘗試:

class MyAccountControllerCore extends FrontController 
    public function initContent() 
    {   
     $this->context->smarty->assign('firstname', 'Doug'); 
     Parent::initContent(); 
    } 
} 

問候

+0

是的,最後回答幫助了我。你知道是否有可能在'MyAccountController'中獲得客戶羣? – Reitrac

+0

Yes add: $ this-> context-> smarty-> assign('listgroup',$ this-> context-> customer-> getGroups()); – ethercreation

+0

它的工作,謝謝,另一個小問題,是否有可能在smarty添加如果條件與PHP VAR?例如{if {$ groupe} == 1}? – Reitrac

0

你沒有使用「全球」smarty。 你應該使用:

$this->context->smarty->assign('firstname', 'Doug'); 
+0

胡胡感謝您!你救了我...... :)你知道是否有可能在'MyAccountController'中獲得客戶羣嗎? – Reitrac