我被要求在这个php/smarty页面中包含一些html代码片段。在付款之前,它基本上是一个概览页面末尾的销售协议。如何在php/smarty中包含静态html
将静态html包含到我的php/smarty模板中的代码是什么?
谢谢...
我被要求在这个php/smarty页面中包含一些html代码片段。在付款之前,它基本上是一个概览页面末尾的销售协议。如何在php/smarty中包含静态html
将静态html包含到我的php/smarty模板中的代码是什么?
谢谢...
你的意思是包含一个包含静态HTML的文件吗?
{include file="htmlfile.html"}
编辑
由于文件仅仅是HTML,它可能是更好地使用{fetch}
,例如
{fetch file="path/to/html/file.html"}
For local files, either a full system file path must be given, or a path relative to the executed php script.
如果你想包括包含JavaScript或类似的一些代码,你可以使用 {literal}{/literal}
标签 到inlude你可以使用{include file="htmlfile.html"}
汤姆说一个文件。
之前显示模板,在PHP文件试试这个:
$smarty->assign('Sectionfile','section-name.html');
$smarty->display('template.tpl');
在模板本身
:
{include file="html_dir/$Sectionfile"}
像任何其他模板,Smarty的文件是HTML文件本身。你可以将你的HTML粘贴到smarty模板中。
是的,这是我第一个需要完成的解决方案,在我的视角中也是最好的,因为这个文件只包含在一个页面中,但我的老板坚持要把它作为一个包含。 – Kyle 2010-04-19 11:03:44
这就是我的意思。但它返回这个:'警告:Smarty错误:无法读取资源:“custom:betalingsvilkar.html”in /home/euroworkerno/www/library/smarty/libs/Smarty.php on line 1095' – Kyle 2010-04-19 10:53:08
'function trigger_error($ error_msg,$ error_type = E_USER_WARNING) { trigger_error(“Smarty error:$ error_msg”,$ error_type); }'这就是行1095. – Kyle 2010-04-19 10:57:02