Jump to content

Recuperer String Html Template Tpl


Recommended Posts

Pour faire de l'ajax dans un module, j'essaie de récupérer un template sous forme de string.

 

if($this->context->customer->logged){

$this->smarty->assign('customerName' , $this->context->customer->firstname.' '.$this->context->customer->lastname);

$tpl = $this->display(__FILE__, 'blockaccountlogged.tpl'); // le code s'arrête là

$return = array(

'hasError' => 0,

'html' => $tpl, //alors que je veux l'afficher ici

'token' => Tools::getToken(false)

);

die (Tools::jsonEncode($return));

 

Au display le template s'affiche et la page die.

 

J'ai essayé aussi :

$tpl = $this->context->smarty->fetch($this->getTemplatePath('blockaccountlogged.tpl'));

Mais le résultat est le même à la différence près que ma variable ne s'affiche plus.

Une idée ?

Merci

Link to comment
Share on other sites

$smarty = new Smarty();

$smarty->assign('customerName' , $this->context->customer->firstname.' '.$this->context->customer->lastname);

$tpl = $smarty->fetch($this->getTemplatePath('blockaccountlogged.tpl'));

 

Fonctionne mais me prive de fonctionnalités dont j'ai besoin....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...