PHPTAL - taking the step up from smarty
I have really found so many limitations and cumbersome procedures in smarty that I am very motivated to make a move from it, namely one of the biggest drawbacks was the clear lack of XHTML compliancy, meaning that once you start using smarty template files you can forget standards, such as validating with the w3c tidy plugin or using code formatting.
This is where PHPTAL takes a real shine, and with the hint of having PHP5 support on my hosting company I can take the jump into much cleaner more powerful technologies.
PHPTAL is a PHP implementation of ZPT work. To be short, PHPTAL is a XML/XHTML template library for PHP.
While most web developpers continue to use ASP/JSP/PHP tags as the core language of their templates, the Zope community came with a refreshing idea named TAL. The idea was to move presentation actions inside XHTML attributes instead of using plain tags or elements.
Also another fueled comment I found when researching and comparing the templating engine, I found this post
There really is no comparison, PHPTAL is miles ahead, and you only need to just start working with objects to realise how many short-falls Smarty has, and how many nasty hacks you need to do just to get Smarty working with objects. Sure Smarty has support for objects, but it really is very limited.
PHPTAL also has support for wysiwyg editors… in the way PHPTAL doesn’t break the xhtml standards… try editing a Smarty template in a wysiwys editor, it’s near impossible! …you just need to know the tal attributes to put in yourself (not hard, there’s not many of them)
You can also preview PHPTAL templates in a browser before you execute the php to display it, if you try and preview a Smarty template the same way you get mostly garbage. With PHPTAL templates you can design a single template which is usable on both static pages and dynamic pages… With Dreamweaver and its DWT templates, it’s very easy to create an entire static site with a few dynamic sections using PHPTAL which use the same DWT templates.
PHPTAL also keeps more of the logic back in the PHP code where it belongs, Smarty is like another complete language in its own right. Read up about MVC, Smarty can promote breaking out of the MVC ideal.
Fixing errors in your Smarty templates isn’t as easy fixing errors in PHPTAL templates… for a start, PHPTAL 99.9% of the time gives you line numbers where you’ve gone wrong, and useful exceptions to help out too.
I personally consider Smarty as something that was designed for PHP3, updated for PHP4, and hacked to work with PHP5.
Stick with PHPTAL, you won’t regret it.






ARGH! So am I waisting my time working with Smarty?
Comment by Richard Lee — July 21, 2006 @ 3:14 pm
Hmmm just had a read of the PHPTAL site, this idea of moving template actions into XHTML attributes is VERY appealing… My biggest beef with Smarty is the need to add in these “extra” template constructs, i.e.
{if $error ne ""}outside of the HTML so to speak. Tell me if I’m wrong but there’s this tendency to add complex logic to the templates through these constructs!?.Here’s some quick examples of printing a dynamic table using PHP, Smarty and finally PHPTAL. Which do you prefer?
PHP
<table> <?php foreach($myItems as $item){ echo ' <tr> <td>'.$item.'</td> </tr>'; ?> </table>Smarty
<table> {foreach item="item" from=$myItems} <tr> <td>{$item}</td> </tr> {/foreach} </table>PHPTAL
I think I just answered my previous post!
Comment by Richard Lee — July 21, 2006 @ 3:45 pm
I think we are missing some code here, smarty would have a lot more code if it was complete, something like:
{/foreach}
:)
Comment by Cameron Manderson — July 21, 2006 @ 6:09 pm
Hmm the HTML has been stripped. We really have to fix that.
Comment by Cameron Manderson — July 21, 2006 @ 6:09 pm
Yeah, some of the Smarty code got stripped so had to go do a db edit…I agree,when one of us gets a moment we need to look at whats happening with our code plugin
Comment by Richard Lee — July 21, 2006 @ 8:09 pm
also, PHPTAL is XSS safe by default , that will save you a lot of validation
Comment by judas_iscariote — August 23, 2006 @ 12:18 pm