How to include static html in php/smarty

前端 未结 4 466
独厮守ぢ
独厮守ぢ 2021-01-13 14:49

I have been asked to include some html snippet in this php/smarty page. It\'s basically a sales agreement at the end of an overview page before you pay.

What is the

相关标签:
4条回答
  • 2021-01-13 15:16

    Like any other templates, smarty files are HTML files itself. you can just paste your HTML into smarty template.

    0 讨论(0)
  • 2021-01-13 15:19

    If you are trying to include some code containing javascript or similar, you can use {literal}{/literal} tags to inlude a file you can use {include file="htmlfile.html"} as Tom said.

    0 讨论(0)
  • 2021-01-13 15:32

    Do you mean include a file containing static HTML?

    {include file="htmlfile.html"}

    edit

    As the file is just HTML, it might be better to use {fetch}, e.g.

    {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.

    0 讨论(0)
  • 2021-01-13 15:32

    Before you display the template, in the PHP file try this:

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

    in the template itself:

    {include file="html_dir/$Sectionfile"} 
    
    0 讨论(0)
提交回复
热议问题