html - 将 HTML 文件包含到 Smarty .tpl 文件中

标签 html include smarty

{if $loggedin}

{literal}
{include file="allhead.html"}
{/literal}

{else}

{literal}
{include file="allhead1.html"}
{/literal}

{/if}

如何将包含在 HTML 文件中的代码包含在 smarty .tpl 文件中?我在各种论坛上尝试过不同的解决方案,但都没有用。


你的意思是我必须用这个创建一个 PHP 文件:

<?php
$smarty->assign('allhead', '/public_html/billing/templates/allhead.html');
$smarty->assign('allhead1', '/public_html/billing/templates/allhead1.html');
?>

然后将此添加到 Smarty .tpl 文件中:

{if $loggedin}

{include file="$allhead"}

{else}

{include file="$allhead1"}

{/if}

但是 smarty 模板如何知道它必须检查 PHP 文件中的 $ 变量?

最佳答案

在 PHP 中:

$smarty->assign('allhead1', 'FULL_PATH_T0_FILE');  

在 Smarty 模板中:

<body>
<!-- don't put literal tags around include -->
{include file="$allhead1"}  
</body>

关于html - 将 HTML 文件包含到 Smarty .tpl 文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2898010/

相关文章:

html - 无论浏览器大小如何,如何让 <div> 始终位于浏览器窗口的右上角?

Python:使用 Beautifulsoup 从 html 中获取文本

C++ - 错误 : 'function' was not declared in this scope

c++ - 我应该在 C++ 程序中包含 <xxxx.h> 或 <cxxxx> 吗?

php - 将两个循环转换为 smarty

javascript - 使用 jquery 切换多个复选框

javascript - 单击不同页面时接收表值

java - 包含 Java 文件,就像 PHP 的 include 一样

javascript - 将smarty数组转换为javascript数组

html - 使用 SMARTY 截断 HTML 格式的文本