Theme function

How to theme the User Login page in Maintenance Mode

A recent client wanted to remove everything from the user login page when the site was in maintenance (or Site off-line as its referred to in most system messages and documentation). Just showing the user login form when the site is off-line actually makes a lot of sense because whats the point of showing things like primary links, search block or whatever else might show on your normal user login page.

Field Type Suggestions in Drupal 7

NOTE: I have submitted a feature request to Drupal 7 to have this included in core - if you have some opinion on that please see Field Type Template Suggestions

Today I finally got around to testing out the new field suggestions in Drupal 7. If you're not familiar with the standard suggestions in short you can either use field templates or override theme_field using a naming convention not unlike we do with preprocess functions. What struck me as kind of odd was the lack suggestions for field types—maybe there's a very good reason for this such as performance, I don't know, but I thought it might be interesting to see if I could use them, if I wanted to.

Add first and last classes to secondary local tasks

We had a project recently where we needed to add first and last classes to Drupals secondary local tasks. I was in a bit of a hurry so instead of trying to figure this out myself I Googled it and pretty quickly found this post on Drupal.org which seemed to fit the bill. Problem is the post doesn't actually tell you how or where to use the snippet, which isn't much good for those of you struggling with Drupal in the first place.

Page template suggestions for taxonomy vocabs

Drupal's template suggestions are plentiful and pretty powerful stuff, however, given all the options there are some noteable oversights. In particular the ability to use page-taxonomy suggestions per vocabulary, something like page-vocab-1.tpl.php to theme all taxonomy term pages in vocabulary 1 (where 1 is the VID or vocabulary id).

To achieve this we turn to our trusty preprocess_page function which by now every Drupal themer worth his or her salt knows all about.

Give your Nodes some Class

In this short tutorial I'm going to show you how to set a unique class on your nodes based on taxonomy terms, which is something I've been asked about more than once or twice.

First thing you need is a template.php file and inside that declare a preprocess function. We're going to use this function to build an array of class names and then print them in node.tpl.php. With me? Ok.

Setting Blocktheme Classes with subtheme_preprocess_block

I've become a big fan of the fantastic Blocktheme module. Up until now I've followed the README instructions and either built blocktheme templates or just printed the $blocktheme variable in my block.tpl.php and block-xxx.tpl.php templates.

Thats all well and good, but in my current project I wanted to be able to theme blockthemes by region. The main reason for this is we are making just very minor changes to the block styles depending on the region and we see no point in creating additional blockthemes.

Pages