drupal 6

Adding a cache table for a module

Drupal Core provides a central caching system. If your module has needs for caching that fall outside the default cache tables, it can have its own cache table (or bin) that uses the same interfaces.

Adding a custom cache table is as simple as adding it to the site's install schema.

Drupal 7

Set a Drupal module's weight on install using db_update

The weight of a module determines the ordering in which it will be called during callback hooks. eg Given 2 modules which implement hook_menu_alter(), the one with weight 0 will run before the one with weight 10.

If you know the weight that a module needs to be, and you can be very sure that no other module might get in there and change it, it can just be set statically.

Views template override function for a field to pad top of an image to center it

This method is dependent on running the images through an image style to ensure that the width and height tags are added to the img tag, and that the height of the area to be centered is known. This is pretty easy for fixed sized areas fitting images, like in a list or gallery.

Instead of making a views-view-field--featured--field-image-cache-fid.tpl.php file, this function produced the output instead. In this example, I know that the height of the div is of a fixed 155px in height.

Views theme template functions instead of template files

Normally when overriding a views template it's a case of create a file like views-view-unformatted--featured.tpl.php. But this is actually a performance hit when it could be picked up as a theme template function instead.

The above function would be

Drupal 6 themed images with ImageCache and Thickbox or Lightbox

This is mostly because I can't remember how to do this all the time.

The ImageCache preset is 'vpthumb' in this case.

Subscribe to RSS - drupal 6