【问题标题】:Include HTML file into Smarty .tpl file将 HTML 文件包含到 Smarty .tpl 文件中
【发布时间】: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 呢?

【问题讨论】:

  • 您的包含调用不应包含在文字标签中...

标签: html include smarty


【解决方案1】:

在 PHP 中:

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

在 Smarty 模板中:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-28
    • 2015-08-15
    • 1970-01-01
    • 1970-01-01
    • 2021-10-31
    • 1970-01-01
    • 2010-10-01
    • 2014-03-01
    相关资源
    最近更新 更多