On Tue, 13 Jul 2004 10:48:34 -0400, John W. Holmes <[EMAIL PROTECTED]> wrote: [snip] > Everyone has their own ideas on whether this is needed and what kind of > templates to use. There are a ton of engines out there that you can use. > Some are simple and some turn into programming languages of their own > and just present another layer of failure/difficulty. Some people > recommend just using PHP both in your business and presentation layer as > this is what PHP was originally designed for. > > Personal preference. :)
Personal preference indeed -- this is likely to be a long thread! If you're new to this and finding template engines confising, I'd urge you to start out by just doing "pure PHP" templating, i.e. what John is describing in the last sentence of his first paragraph. You get the structural benefits of templating (more readable program logic, more readable HTML) without having to learn any new syntax. In a nutshell, this means that you have a script that prepares data, and another (mostly HTML), included by the first, that presents it. The first, let's call it page.php, will be something like this: <?php $foo = $_GET['foo']; // get example parameter passed by user $foo = htmlspecialchars ($foo); // example transformation; prevent user from injecting HTML $foo = strtoupper ($foo); // example transformation; we want this displayed in all caps $date = date ('Y-m-d'); // example data; date in '2004-07-13' format require_once 'page.tpl.php'; // render page using template, fail if not found ?> and page.tpl.php will be something like this: <html> <body> <h1>Current foo status: <?= $foo ?></h1> <small>Page created on <?= $date ?></small> </body> </html> This is a minimal example, but even without further refinements this approach will create much more readable and maintainable code than the big-ball-o-mud interwoven-PHP-and-HTML style of development. The argument against template engines is well presented here: http://phppatterns.com/index.php/article/articleview/4/1/1/ Personally, I use Smarty for sites that need complex templating, and pure PHP templating for everything else. pb -- paul bissex, e-scribe.com -- database-driven web development 413.585.8095 69.55.225.29 01061-0847 72°39'71"W 42°19'42"N -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php