[thelist] PHP Templating recommendations

Travis tbrunn at pgmusic.com
Wed Feb 2 23:16:21 CST 2005

Just thought I'd throw this out there as another option that might be of
interest, though this is also likely overkill for a small project...

If you can turn on the XSLT extension in php you could use that as a
templating system - useful if you need to display data of a nested tree, or
anything like that (I don't know much about Smarty, but I did look into it
once and seem to remember reading that it wasn't capable of that sort of
thing...  Though if I'm mistaken please forgive).

With php's xslt extension you can use all the power of xsl stylesheets, if
that appeals.

Anyhow,  here are some rather good tutorials by Tony Marston on how to put
this sort of system together... (The amount of code is actually quite

A tutorial on how to convert data from a db into xml:
http://www.zend.com/zend/tut/tutorial-DOM-XML.php (This was written with
php4 in mind.  I haven't checked to see what's going on with the dom_xml
extension in php5 but there might be a better way to generate xml now.)

...and, once you've got the xml data, a tutorial on how to use the built-in
xslt extension to turn it into graphic goodness:


----- Original Message -----
From: "Maximillian Schwanekamp" <lists at neptunewebworks.com>
To: "Matt Warden" <mwarden at gmail.com>; <thelist at lists.evolt.org>
Sent: Wednesday, February 02, 2005 2:48 PM
Subject: Re: [thelist] PHP Templating recommendations

> Matt Warden wrote:
> > Point taken. But, as I said in my last email, there are a lot of cases
> > out there where Smarty would be appropriate and beneficial, but
> > developers excuse ignoring it by saying that it is 'like a
> > sledgehammer for a thumbtack' or other such phrases, when what they
> > really mean is that they are afraid to learn a new syntax (which is
> > ridiculously trivial). I am not saying it applies here.
> In a bit of self-defense as the OP here, I'd like to say that I think
> Smarty is excellent, and I've been using it increasingly regularly for
> the past 6 months or so.  It's really not hard to get started in Smarty,
> and the overall benefits are huge, especially once you really start
> getting into it.  Rather like PHP itself... :)
> >>Smarty is a non-trivial amount of code (~4000 lines) and requires some
> >>server infrastructure as well. <snip />
> > I didn't have to change any server configuration. It's just a couple
> > included files. Your codebase argument is valid, though.
> The "sledgehammer" analogy came up for me when I noticed that
> non-cacheable {section}{/section} blocks (e.g. search results pages)
> were being compiled and sent to the browser a bit too slowly.
> What I've gone with is to go ahead with Smarty, but instead of using
> {section} blocks in Smarty, I'm instead doing a small set of utility
> classes to generate the HTML within php, and put the block of HTML
> content in the Smarty template with a simple {$var}.  With Smarty's
> caching features for the mostly-static elements, this seems to me a good
> compromise.
> --
> Maximillian Von Schwanekamp
> http://www.neptunewebworks.com/
> --
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !

More information about the thelist mailing list