开发者

Include HTML file into Smarty .tpl file

开发者 https://www.devze.com 2023-01-01 01:29 出处:网络
{if $loggedin} {literal} {include file=\"allhead.html\"} {/literal} {else} {literal} {include file=\"allhead1.html\"}
{if $loggedin}

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

{else}

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

{/if}

How do I include the code contained into an HTML file in a smarty .tpl file? I've tried different solutions on various forums, but none work.


You mean I have to create a PHP file with this:

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

Then add into the Smarty .tpl file this:

{if $loggedin}

{include file="$allhead"}开发者_开发知识库

{else}

{include file="$allhead1"}

{/if}

But how will the smarty template know it got to check the $ vars from the PHP file?


In PHP:

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

In Smarty Template:

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

精彩评论

暂无评论...
验证码 换一张
取 消