这不显示:
include {php} echo "hello" {/php}
Smarty.class.php
和smarty_security.php
我有$allow_php_tag = true;
但{php} echo "hello" {/php}
不起作用。我这边没有显示"你好"。
为什么不呢?
不建议在 Smarty 模板中使用 PHP,在 Smarty 3.1 中已弃用但是,如果您确实需要在 Smarty 模板中使用 PHP,则需要使用SmartyBC
类而不是Smarty
类。为此:
-
转到
config/smarty.config.inc.php
-
改变
require_once(_PS_SMARTY_DIR_.'Smarty.class.php');
到
require_once(_PS_SMARTY_DIR_.'SmartyBC.class.php');
- 改变
$smarty = new Smarty();
到
$smarty = new SmartyBC();
就是这样。你不需要做更多的事情(在Prestashop 1.6.0.8中测试(