包含在 .tpl 中不起作用



这不显示:

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

Smarty.class.phpsmarty_security.php我有$allow_php_tag = true;{php} echo "hello" {/php}不起作用。我这边没有显示"你好"。

为什么不呢?

不建议在 Smarty 模板中使用 PHP,在 Smarty 3.1 中已弃用但是,如果您确实需要在 Smarty 模板中使用 PHP,则需要使用SmartyBC类而不是Smarty类。为此:

  1. 转到config/smarty.config.inc.php

  2. 改变

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

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

  1. 改变

$smarty = new Smarty();

$smarty = new SmartyBC();

就是这样。你不需要做更多的事情(在Prestashop 1.6.0.8中测试(

最新更新