PHPTemplate theme engine

Last modified: April 4, 2009 - 23:38

PHPTemplate is a theme engine written by Adrian Rossouw (who was also behind the theme reforms in Drupal 4.5).

It uses individual something.tpl.php files to theme Drupal's theme_something() functions. Drupal's themeable functions are documented on the Drupal API site. Every file contains an HTML skeleton with some simple PHP statements for the dynamic data. Thus, PHPTemplate is an excellent choice for theming if you know a bit of PHP: with some basic PHP snippets, you can create advanced themes easily.

If you don't know PHP, then PHPTemplate can still be a good choice because only small bits of code are involved. They can just be copy/pasted into your template.

An extended Forum discussion provides some of the reasoning behind the creation of PHPTemplate.

Tips: Print out available variables

Print the variables array

<?php
print '<pre>';
print_r(get_defined_vars());
print
'</pre>';
?>

Print the variables array with the HTML markup

<?php
print '<pre>';
print
htmlspecialchars(print_r(get_defined_vars(), TRUE), ENT_QUOTES);
print
'</pre>';
?>

 
 

Drupal is a registered trademark of Dries Buytaert.