Smarty — Good Template engine for PHP
Just when i wrote my previous post, I needed it myself already. Had to install ezSQL onto my new project.
When installing this i figured that it would be nice to use a template engine. Since i have experience with Smarty I downloaded it and installed it also to my new project.
What is Smarty?
Smarty is a very easy to use template engine. I’ll show you some examples below:
// At regular sites you would use this code: <?php $row = array("1","2","3","4"); foreach ($row as $newrow) { echo('this is no. '.$newrow); } ?> //in Smarty you would write this: // At index file <?php $smarty->assign('row',array("1","2","3","4")); ?> //At template file: {foreach from=$row item=item} This is no. {$item} {/foreach}
It looks like a lot of extra work, but you can use ths array everywhere. Also Smarty forces you to use functions. And with the assign key you can enter a function in it.
This makes Smarty very usefull for OOP applications. And always easy to extend without a lot of nonsense.
I recon you don’t know a lot about this Smarty. But I’ll show you new examples in the near future.
Information and download at www.smarty.net