Quote:
Originally Posted by crcool75
Tal,
What do you mean by "No display code should be in there"?
|
PHP files are for logic. PHP works with logic faster than smarty.
TPL files are for display. Smarty works with templates and caching and such faster than with logic. Performance will drop with php stuff inside TPL files.
All the info needed to be displayed should be passed as variables to the TPLs which then format it as needed.
So something like below wouldn't be advised in a php file:
Code:
<?
$var = 123456;
echo $var;
?>
Instead it should be:
Code:
$var = 123456;
$smarty->assign("var",$var);
The reverse is true for TPLs.
Bad:
Code:
{php}
$var1 = 1;
$var2 = 1;
$var3 = $var1 + $var 2;
{/php}
{$var3}
Good:
PHP File:
Code:
$var1 = 1;
$var2 = 1;
$var3 = $var1 + $var2;
$smarty->assign("varName",$var3);
TPL file: