views:

525

answers:

2
{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.

+1  A: 

In PHP:

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

In Smarty Template:

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

Dear Jack,

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?

Leonarth
@Leonarth I am not sure I understand your question. Did it work for you?
Jack
No, didn't work, because I don't know how to use you suggestion.I need to include 2 HTML files in a .tpl file.What is it with the PHP file? I insert the PHP code into the .tpl?
Leonarth