Theme development for Drupal

Date: Thu Dec 05 2013 Drupal Themes
Drupal has a flexible theming system which offers a lot of power, but can be a bit confusing. The Theming overview gives some high level guidance.

A theme engine is an intermediate layer allowing for multiple tagging languages to be used. However starting with Drupal 5 the PHPTemplate system was incorporated in the Drupal core and it is the default method.

With PHPTemplate one writes .tpl file using PHP syntax to write the HTML for layout of specific elements. Since it is PHP syntax the HTML can include PHP snippets to customize the output.

Anatomy of a Drupal theme gives an overview of the components that go into creating a theme. For example the overall page layout is defined in page.tpl.php, the layout of a block is defined in block.tpl.php and so on.

Overriding themable output discusses how to change the default behavior and rendering of individual thingymajobs. When a drupal module wants to generate the xHTML for a given thing it is supposed to call a theme_xyzzy function. The thing being theme'd is specified at a high level such as "block" and the theming system can take that request to theme a block and end up calling either a template (block.tpl.php) or a theme function to render that thing (theme_block).