[geeklog-devtalk] Optimizing MySQL (was: SPAM Article)
Michael Jervis
mike at fuckingbrit.com
Fri Mar 4 02:46:48 EST 2005
> The problem is that once you decide on a template engine,
> you're basically stuck with it ...
Not necessarily true, it entirely depends on how you design your templating
support. I've seen two alternative approaches to the one in geeklog which
mean you can do exactly what you like.
The first is to use an adapter pattern and abstract the template engine you
use. Then you can swap out the template engine very easily.
The second, is the way Drupal does it. They wrote "theme" functions. So,
when you theme something you call out to a themeing function with the item
you want to theme. Modules have default functions to display their
information in a default fashion if you don't override the theme. Template
engines can then provide their own version of that function.
If you say have a function theme_page then some PHP handles themeing it.
Then, if you are using a smarty theme engine wrapper for drupal, and that
item overrides theme_page, it can then instantiate a Smarty object and use
it's templating on that.
It seems to work pretty nicely. It's not a true adapter pattern, it's
evolved from the kludgy way themeing was originally done. Originally, they
just separated out the display logic so people could easily re-write the
functions (I think) then this expanded into hooking to replace functions,
and re-theme things via real themeing approaches.
However, what a lot of people tend to forget, is PHP /is/ a templating
language, and includes compiling/caching within itself. I like the simplet
package (http://simplet.sourceforge.net I think) which allows you to use php
to theme, merely providing a way to cache (PEAR::cache) and abstract the
templating to separate display and business logic.
Anyway, that's all by-the-by, Geeklog /is/ stuck with it's templating
engine, but software doesn't /have/ to be stuck with it's templating engine.
Mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3030 bytes
Desc: not available
Url : <http://eight.pairlist.net/pipermail/geeklog-devtalk/attachments/20050304/0fa5cc78/attachment.bin>
More information about the geeklog-devtalk
mailing list