Drupal theming for designers, continued.

Drupal Theming – Part 2 – Controlling themes

This is a continuation of the earlier article on Drupal theming for designers.

Near the end of the previous article, we mentioned other *.tpl.php files used by themes. These files, and any others that you create, using Drupal’s PHPTemplate file naming convention, you are able to ‘override’ the default display:

  • node.tpl.php
  • block.tpl.php
  • box.tpl.php
  • comment.tpl.php

Drupal’s PHPTemplate theme engine uses the content generated by these files in page.tpl.php, as the following diagram demonstrates:

More control means more power

Using the *.tpl.php you can control:

  • the display of different content types, such as blogs, forum posts, or anything else you create. What are 'content types' (node-[content type].tpl.php)
  • the display of content in edit-mode (node-edit.tpl.php)
  • the display of individual nodesWhat is a 'node' (node-[node ID number].tpl.php)
  • the display of the front page

Controlling the content being passed to the *.tpl.php using variables

Let’s look at the variables used in page.tpl.php and node.tpl.php:


Here, we see page.tpl.php prints variables such as $sidebar_left and $mission.


In node.tpl.php we see variables such as $sticky.

You can use template.php to override functions returning these variables and you can intercept other variables:

This template.php example, from the Zen theme, demonstrates function overrides:

  • zen_regions
  • zen_breadcrumb

Here is the documentation listing all themable functions: http://api.drupal.org/api/group/themeable/5

A brief note regarding regions

It also demonstrates variable re-definition, which is scope controlled:

  • $vars[variablename]

Here is documentation listing all variables available in page.tpl.php, node.tpl.php, and block.tpl.php.

For more on creating Drupal themes, I recommend the following:

Comments

As great as part 1. This is

As great as part 1. This is the most useful tutorial for the beginners to design their own themes.

software reviews

Can these themes be

Can these themes be implemented on something else and not a Drupal template?
---
link building company

Apress.com link is incorrect

The correct link for the apress pdf file to download is: http://apress.com/resource/bookfile/3486

that should correct any link problems.

I had no idea that Drupal

I had no idea that Drupal themes are created using PHP now. How do they fit with older ones that are not using this programming language? I tried combining pHp with my old code on offshore corporation but nothing really changed.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha
This question is used to make sure you are a human visitor and to prevent spam submissions.
Copy the characters (respecting upper/lower case) from the image.