mirko
mirko

Reputation: 65

Include in a .tpl does not work

This does not display:

include {php} echo "hello" {/php}

Smarty.class.php and smarty_security.php I have $allow_php_tag = true; but {php} echo "hello" {/php} not work. No display "hello" on my side.

Why not?

Upvotes: 1

Views: 920

Answers (1)

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111889

Using PHP in Smarty templates is not recommended and has been deprecated in Smarty 3.1 However if you really need to use PHP in Smarty template you need to use SmartyBC class and not Smarty class. To do that:

  1. Go to config/smarty.config.inc.php

  2. Change

require_once(_PS_SMARTY_DIR_.'Smarty.class.php');

into

require_once(_PS_SMARTY_DIR_.'SmartyBC.class.php');

  1. Change

$smarty = new Smarty();

into

$smarty = new SmartyBC();

That's it. You don't need to do anything more (tested in Prestashop 1.6.0.8)

Upvotes: 2

Related Questions