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