SmartyBC(向后兼容包装)在PrestaShop中不起作用

时间:2014-07-22 13:09:22

标签: php smarty prestashop

正如Smarty的指示中所述,为了在最新的PrestaShop中使用include_php等弃用函数,我必须从Smarty.class.php切换到SmartyBC.class.php。我是通过smarty.config.inc.php以下几行中的方式做到的:

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

global $smarty;
// $smarty = new Smarty();
$smarty = new SmartyBC();

但是,在主题{include_php file='./custom_php/manufacturers.php'}中使用header.tpl仍会导致空白屏幕。来自php_error_log的错误:

[22-Jul-2014 15:05:55 Europe/Warsaw] PHP Notice:  Undefined property: SmartyBC::$trusted_dir in C:\BACKUP\Dropbox\!_PC\LOCALHOST\_INTERCLICK\trzmiel5\tools\smarty\Smarty.class.php on line 676

[22-Jul-2014 15:05:55 Europe/Warsaw] PHP Fatal error:  Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "C:\BACKUP\Dropbox\!_PC\LOCALHOST\_INTERCLICK\trzmiel5\themes\trzmiel\header.tpl"  on line 101 "{include_php file='./custom_php/manufacturers.php'}" {include_php} file './custom_php/manufacturers.php' is not readable' in C:\BACKUP\Dropbox\!_PC\LOCALHOST\_INTERCLICK\trzmiel5\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php:667
Stack trace:
#0 C:\BACKUP\Dropbox\!_PC\LOCALHOST\_INTERCLICK\trzmiel5\tools\smarty\sysplugins\smarty_internal_compile_include_php.php(81): Smarty_Internal_TemplateCompilerBase->trigger_template_error('{include_php} f...', 101)
#1 C:\BACKUP\Dropbox\!_PC\LOCALHOST\_INTERCLICK\trzmiel5\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php(485): Smarty_Internal_Compile_Include_Php->compile(Array, Object(Smarty_Internal_SmartyTemplateCompiler), Array, NULL, NULL)
#2 C:\BACKUP\Dropbox\!_PC\LOCALHOST\_INTERCLICK\trzmiel5\tools\smarty\sysplugins\smarty_internal_templ in C:\BACKUP\Dropbox\!_PC\LOCALHOST\_INTERCLICK\trzmiel5\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 667

1 个答案:

答案 0 :(得分:0)

似乎trusted_dir属性仅在使用安全策略时可用:

class My_Security_Policy extends Smarty_Security {
  public $trusted_dir  = './custom_php/';

}
$smarty = new SmartyBC();
// enable security
$smartyBC->enableSecurity('My_Security_Policy');

所以你应该在这里提供正确的路径(我不知道它是否相对 - 你应该试一试)然后你应该可以在你的模板文件中使用manufacturers.php文件了但是你此处还应该查看正确的文件路径。