Justin French said: > PHP itself is a great templating language :) I've been studying on this myself. For some reason I didn't see this (is it not explained well enough in books/websites/articles? Dunno.)
I used to code like so (shorthand), mixing business logic with presentation: <html> <body> <?php $result = mysql_query ("SELECT * FROM users WHERE id = '".$_GET["id"]."'); $row_array = mysql_fetch_array ($result); ?> Name: <?=$row_array["name"];?><br> Address: <?=$row_array["address"];?><br> State: <?=$row_array["state"];?><br> ... This was big trouble with my Front Page developer. She's a real estate agent. She needs something visual and can't spend time learning something else. Front Page's PHP plugin was buggy at best. Enter Smarty. With Smarty, I was effectively separating business and presentation logic: $page = new Smarty(); $result = mysql_query ("SELECT * FROM users WHERE id = '".$_GET["id"]."'); $row_array = mysql_fetch_array ($result); $page->assign("name", $row_array["name"]); $page->assign("address", $row_array["address"]); $page->assign("state", $row_array["state"]); $page->display("template.tpl"); --- <html> <body> Name: {$name}<br> Address: {$address}<br> State: {$state}<br> ... But one of the original intentions of PHP was as a templating system. It just takes a little planning and thinking to use it as such: $result = mysql_query ("SELECT * FROM users WHERE id = '".$_GET["id"]."'); $row_array = mysql_fetch_array ($result); $name = $row_array["name"]; $address = $row_array["address"]; $state = $row_array["state"]; $include("template.tpl"); --- <html> <body> Name: <?=$name;?><br> Address: <?=$address;?><br> State: <?=$state;?><br> ... A kool side effect is I don't have to learn another language. And it's faster because less code loads on each page launch (Smarty's code must be loaded on every page load). At worst, I lose caching features (however other native PHP options exist, and/or use Zend) and some of the nice Smarty functions such as html_options (which might be easily replaced by phpHTMLlib or another widget library). So while Smarty isn't at all bad, it doesn't appear to be *necessary* to separate business logic from presentation. And I don't need to learn another programming language. So I may be going back to straight PHP :-) For more info, read this: http://www.phppatterns.com/index.php/article/articleview/4/1/1/ This article is rather rigid, stating that template engines are all bad. I just see them as another tool, but not the *must have* I thought they were before. Thanks to Jochem Maas <[EMAIL PROTECTED]> for helping me open my eyes. /dev/idal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php