繁体   English   中英

如何在php / smarty中包含静态html

[英]How to include static html in php/smarty

我被要求在这个php / smarty页面中包含一些html片段。 在付款之前,它基本上是概述页面末尾的销售协议。

将静态html包含到我的php / smarty模板中的代码是什么?

谢谢...

你的意思是包含一个包含静态HTML的文件?

{include file="htmlfile.html"}

编辑

由于文件只是HTML,因此使用{fetch}可能更好,例如

{fetch file="path/to/html/file.html"}

对于本地文件,必须提供完整的系统文件路径,或者相对于执行的php脚本的路径。

与任何其他模板一样,智能文件本身就是HTML文件。 您可以将HTML粘贴到智能模板中。

如果您尝试包含一些包含javascript或类似代码的代码,您可以使用{literal}{/literal}标记来包含您可以使用的文件{include file="htmlfile.html"}如Tom所说。

在显示模板之前,在PHP文件中试试这个:

$smarty->assign('Sectionfile','section-name.html');
$smarty->display('template.tpl');

在模板本身:

{include file="html_dir/$Sectionfile"} 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM