[英]Include PHP File in Smarty tpl
I want to include a PHP script that outputs some HTML in productdetail-full.tpl file (Smarty / Prestashop 1.6.x)我想在 productdetail-full.tpl 文件(Smarty / Prestashop 1.6.x)中包含一个输出一些 HTML 的 PHP 脚本
I tried:我试过:
{php}
include('show-stock-pos.php');
{/php}
AND和
{include_php 'show-stock-pos.php'}
But they are both deprecated.但它们都已弃用。 Any suggestions?
有什么建议?
Thanks!谢谢!
You should use SmartyBC - Backwards Compatibility Wrapper
for this since it's not recommended using php code in the templates.您应该
SmartyBC - Backwards Compatibility Wrapper
使用SmartyBC - Backwards Compatibility Wrapper
,因为不建议在模板中使用 php 代码。
Instead of:代替:
require_once('path/to/smarty/libs/Smarty.class.php');
$smarty = new Smarty();
Use:用:
require_once('path/to/smarty/libs/SmartyBC.class.php');
$smarty = new SmartyBC();
And you will be able to use PHP in your Smarty template files.您将能够在 Smarty 模板文件中使用 PHP。
More info about this here:关于这里的更多信息:
https://www.smarty.net/docs/en/bc.tpl https://www.smarty.net/docs/en/bc.tpl
Prestashop is a modular system that uses hooks to display information. Prestashop 是一个模块化系统,它使用钩子来显示信息。
According to Prestashop standards and solutions, you should use hooks and module:根据 Prestashop 标准和解决方案,您应该使用钩子和模块:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.