2017-05-29 69 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