10-18-2007, 04:35 PM
|
#20 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
Smarty seems quite easy to use tbh, but if u really wanna do your own im sure that you could build on some of the examples above, just tinker with them, its the best way to teach yourself PHP or indeed any langauge (i mean learn by example, i dont mean copy code and just use it, that would get u nowhere).
a simple smart template could be constructed like this:
PHP Code:
<?php
require 'Smarty.class.php';
$smarty = new Smarty;//create new smarty object
$smarty->assign('Username', 'Sam');
//assign smarty variable Username with the value 'Sam' in the template file
$smarty->display('index.tpl');
//tell smarty which template file you want to use
?>
now we need to create the "index.tpl" template page that we told smarty to use
HTML Code:
<html>
<body>
Welcome {$Username} <!--Smarty variable-->
</body>
</html>
Will output: "Welcome Sam" when run
simple really and it provides the much coverted seperation between logic and presentation, which makes scripts alot easier to maintain and extend.
|
|
|
|