use include in tpl files with smarty in prestashop modules

The smarty version included in prestashop seems to be slightly different than the offical release.

If you want to use the include instruction in a tpl file, you have to be aware of these limitations inside the instruction:
  • you cannot concat strings
  • you must use full path
One easy way I've found to achieve this is to use the following code in your .php file:
// Get the full path of the mytpl template
[...]
$smarty->assign('one_var', dirname(__FILE__).'/mytpl.tpl');
return $this->display(__FILE__, $this->name.'.tpl');
And the following code in your .tpl file:
[...]
{include file=$one_var}
[...]

Comments

Popular posts from this blog

Resolve "Cannot download packages whilst offline" issue in Deja-Dup backup software

ubuntu 20.04 / netplan / change mac address and static ip

wireshark ssh remote connect on linux server