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

Just about every very good article features a very good thesis. Nevertheless that thesis is only as effective as this assist inclined to that as a result of tales, suggestions, along with thinking. This post talks about along with illustrates just how good examples needs to be created to support this thesis divorce lawyers atlanta very good article.

transfer essays (not verified) | Wed, 07/23/2014 - 15:11 |

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

Guest (not verified) | Thu, 07/10/2008 - 12:40 |

Can these themes be implemented on something else and not a Drupal template?

Guest (not verified) | Wed, 07/02/2008 - 06:10 |

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

that should correct any link problems.

Guest | Wed, 06/18/2008 - 01:41 |

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.

Guest (not verified) | Fri, 06/06/2008 - 07:56 |

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.

More information about formatting options