Building themes for Drupal since ages ago...

Drupal Themable Functions - Where the Fun Really Begins

August 7, 2008 by Jeff

Drupal includes these groovy things called theme-able functions. A function is a bit of PHP that does something - like generate the output of the breadcrumbs or menu links.

When a function in Drupal is theme-able, it means we can override the default function and modify the output of it. Now that is where the fun really begins!

Over the next 6 months or so (yes, really, 6 months) I'm going to attempt to post about every single theme-able function in Drupal 6 (there's a lot), and show you a simple modification to each one.

First, lets have a look at these functions, surely the first thing we want to know is which of all the functions in Drupal are theme-able, right?

Thank-fully the good people over at Drupal made it real easy to find them all in one place - http://api.drupal.org/api/group/themeable.

There's some excellent information about theme-able functions on that page, so be sure to visit it and read up.

Now, you'll notice that all the core theme-able functions begin with theme_ which is great as its another sign that the function can be themed. Its also the first thing we change when over riding the function, for example...

<?php
function theme_xml_icon($url) {
 
// normal code here...
}
?>

... becomes,

<?php
function mytheme_xml_icon($url) {
 
//normal code here...
}
?>

Where "mytheme_" is the name of your theme.

Ok, so enough of the overview, lets get down to business! Just for the record, I've decided to work in reverse alphabetical order (more so I can actually remember what I've covered), but if you have a special request let me know:), so that means its the xml icon function up first, and that I will attack in the next lesson.

Comments

Post new comment

Leave a comment, suggestion or ask a question!

I only ask that you respect the comments of others and keep it clean.

You can use some basic html such as a, em, strong, cite, code, ul, ol, li, dl, dt, and dd. Line-breaks and paragraphs will be inserted automatically.

You can use Markdown if you want.

If Mollom asks, please fill out the captcha.