[development] .tpl-ifying Drupal

Earl Miles merlin at logrus.com
Fri May 4 18:09:13 UTC 2007

Vladimir Zlatanov wrote:
>     The one place that the alternative engines will have to do real work
>     will be
>     that they should probably ship with their own versions of all the
>     .tpl.php
>     files that Drupal 6 will ship with.
> I can see one problem with converting every nook and cranny theme_ 
> function into .tpl and that is speed. It is related to the number of 
> files loaded, to make matters worse, I doubt that any of the bytecode 
> caches will help with that for heavy duty sites. That is unfortunate, 
> because it is a rather elegant solution, fitted to how drupal works. 
> Having said that, there are possibilities to improve it, depending what 
> are we ready to trade. Caching - to db or a precompiled file full of 
> theme_ functions are just two of the possibilities, you loose dynamism, 
> but for production sites it is not required in the theme layer.

I completely agree. The primary thing to look at when converting a theme 
function to a template is how often this theme function gets used on a page. If 
it's a lot, then absolutely that function should not be converted. Some obvious 
candidates to NOT convert are theme_placeholder() and theme_username(). Making 
these functions into templates don't buy us much anyway.

It's definitely a case of 'start with the big ones' and work to the small ones. 
Big ones are often used only occasionally per page; small ones might be used a lot.

More information about the development mailing list