theming

Lightbox2 Slideshows with Multiple-value Imagefields

This is a pretty simple example that illustrates the use of Lightbox2's slideshow feature. In the example, we have an imagefield that allows an unlimited number of images. We only want to render an imagecache version of the first image which, when clicked, will provide a slideshow with the rest of the images in the field. In the example, our field is called "field_product_images".

Showing a nodeasblock block as full content instead of teaser

UPDATE: I've had much better luck with the ​nodeblock​ module. I create an "Editable Block" content type (machine name editblock​) and allow clients to edit these blocks. I've stopped using Node As Block.

By default, the Node As Block module displays a node in teaser mode. After the break, I'll show you how to show the full content of the node using a simple preprocess function in your theme's template.php file.

Show Menu Description Field in Node Add/Edit Form

Many components in Drupal have an optional title or description field. This text usually displays when a user hovers over an item. We had an interesting request: a client wanted to have a box that displayed text which would change every time you roll over a menu item. This can be accomplished using just a small amount of jQuery, and Drupal's built-in menu handling. The menu system in Drupal can handle descriptions on each menu item, however you have to do this through the menu admin.

Using the path_to_theme() Function

When we build Drupal sites we typically have a lot of custom design elements. It is important to be able to display images from the filesystem in a dynamic fashion (non-absolute paths). Should you need to move the site, you wouldn't want to have to reset image paths everywhere. The base_path() and path_to_theme() functions do all of the dirty work for you.

Add Javascript to a Specific Page

There are several ways to add javascript code to a page in Drupal. The method outlined below involves a modification to your theme's template.php file. You'll be editing (and un-commenting if necessary) your theme's preprocess_page function. This basically lets you modify the variables that are available in your page.tpl.php file(s).