Thursday, 23 August 2012
SMARTY programming
I had been learning myself to code this SMARTY programming style. It is quite different from the basic PHP programming. in basic PHP programming we will use <?php some function here..... ?> the PHP tag.
but in SMARTY I have to use additional tag like {$variable} to display data and to manipulate the template.
let say if i want to display this text "hello there! good day huh!". in PHP I will code it like this:
<?php echo "hello there! good day huh!"; ?>
but in SMARTY, I have to assign the values from other file to the template file.
otherfile.php
$hellotext = "hello there! good day huh!";
$smarty->assign('myvariable', $hellotext);
after the assignment, i hade to do the template variable manipulation in the template file( .tpl) .
display.tpl
<html>
<head>
<title>test</title>
</head>
<body>
{$myvariable}
</body>
</html>
when the code is running it will be displayed like this:
hello there! good day huh!
Labels:
SMARTY programming
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment