Add existing class to #page element easily using template.php

In this example we add an existing class to the #page element using template.php

The first thing to do is to open up the file named template.php with your preferred editor. This is located within your theme folder, usually found at: sites/all/themes/*yourtheme*/

If you are using an omega based theme it will look something like this:

How to build a sub-theme (Zen 7.x-5.x) - Manually

The base Zen theme is designed to be easily extended by its sub-themes. You should Not modify any of the CSS or PHP files in the zen/ folder; but instead you should create a sub-theme of zen which is located in a folder outside of the root zen/ folder.

Hide the active language from the language switcher block

The language switcher block does not support the ability to hide the active language, therefore this has to be done in template.php
This will also disable any active language links that use the theme_links

Overview of theme files

A theme is a collection of files that define the presentation layer. You can also create one or more "sub-themes" or variations on a theme. Only the .info file is required, but most themes and sub-themes will use other files as well. The following diagram illustrates the files that are found in a typical theme and sub-theme.

Drupal 6

theming requirements

Drupal 7

drupal 7 theme templates

Adding next & previous links for node types within taxonomy terms (e.g. Image Galleries)

A better way to do this using Custom Pagers module is detailed in the Image module documentation:


The following adds a custom next_prev function to your theme template.php file that allows you to insert NEXT | PREVIOUS type links in your layout.tpl.php files. Where layout might be node.tpl.php, node-image.tpl.php etc.

In the illustrative example snippet below, a simple NEXT | PREVIOUS link is inserted into a custom node-image.tpl.php file linking to the next and previous image within that gallery (taxonomy term).

step 1 of 2

Add the custom next_prev function to your template.php file.

  1. In a text editor like notepad.exe or equivalent, create/edit a template.php file and paste the following snippet
  2. Save your new/edited template.php file and upload it to your active theme folder

function next_prev for Drupal 5

function next_prev($current_nid, $type, $button_type, $label, $class) {
$tid = db_result(db_query(db_rewrite_sql("SELECT tid FROM {term_node} WHERE nid = $current_nid;")));
if (empty($tid)){ //validate that the image 'does' have a tid
return '';

switch ($button_type) {
case 'next':
$sort= 'ASC';
$case = '> ';

Subscribe with RSS Subscribe to RSS - template.php