【发布时间】:2011-02-23 06:57:39
【问题描述】:
{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 文件中的 $ vars 呢?
【问题讨论】:
-
您的包含调用不应包含在文字标签中...