Skip to main content

Drupal tips and tricks

Drupal 6 Block Cache Mode Patch Module

Overview

Drupal 6 has a long-standing bug in the block module (as of 5/10/2011). This bug affects block caching mechanisms. The bug manifests itself if you have block caching enabled.

Once a module's blocks have been registered with the system (in the {blocks} table), the block's caching mode settings are never updated in the {blocks} table, regardless of subsequent cache flushes or other system updates. This is only a problem for modules that change the 'cache' info returned from hook_block op='list' calls.

Uninstalling and re-installing the module won't fix the problem due to another Drupal 6 bug.

More info

This problem impacts any module that changes the caching mode returned in hook_block('info') operation. In particular, the views module allows you to edit a block view's caching mode after creation, but, due to this bug, the changes will never take effect, leading to much head-scratching.

More info

The fix

There are a few core patches available (see Issue 235673, above), but they may not apply cleanly to your Drupal 6 installation; I don't patch core unless there's a critical need. In this case, the patches failed to apply on the sites that needed the fix. So I created a simple custom module that implements the guts of the most recent patch.

Note: You can download the module in the Attachments section, below. Leave a comment if you find this module useful, or, if you have questions about it.

Drupal SQL Query Snippet: Move taxonomy terms from one or more vocabularies into another vocabulary

How do I move Drupal taxonomy terms from one vocabulary to another?

While you can use the excellent Taxonomy Manager module to move taxonomy terms between vocabularies, it's not always worth the trouble to install yet another module. For example, if you are doing this as a one-time merge of several vocabularies into a new vocabulary.

Here's the recipe:

  1. Identify the vocabulary ids (vid) for the source vocabularies. In our example, the source vocabulary ids are 6, 7, 8, and 9.

Drupal PHP Snippet: Delete users with no nodes

Here's a handy PHP snippet to purge user accounts for all users who haven't created any nodes on your site. It's useful when you have a lot of users who have signed but haven't created any nodes.

<?php
 
// Get a list of all users in the site who have not created any nodes, AND uid > 1
 
$sql = "SELECT u.uid FROM {users} u WHERE u.uid NOT IN (SELECT DISTINCT n.uid FROM {node} n) AND u.uid > 1 ORDER BY uid";
 
$result = db_query($sql);
  while(
$row = db_fetch_object($result)) {
 
// delete the user account
 
user_delete(array(), $row->uid);
}
?>

Module: Disable collapsible fieldset animations in Drupal 5

Drupal 5 and later versions provide an animation when you expand or collapse a collapsible form fieldset.

While this is a nifty effect, it can be annoying to some users, and it can slow you down when viewing a web page over a Remote Desktop session in Windows (I use Remote Desktop a lot at home, and the expand/collapse animation can take seconds to complete depending on network speed–it all adds up).

Drupal Tips

Our collection of Drupal-specific tips.

Mollom.com: another spam prevention mechanism for Drupal admins

When trying to keep web site content clean and on-topic, the site administrators often face monumental challenges from spammers.

Mollom.com is an alternative to using the Spam or Akismet modules. It's in beta at present, and it is free of charge at present. It is expected to remain free for low-volume users (for details, please refer to the mollom.com web site - link below.)

Help for the weary Drupal developer: api.drupal.org and drupal.org OpenSearch plugins




OpenSearch Plug-ins for Drupal.org, Drupal 4.7 API, Drupal 5 API, and Drupal 6 API

I've created some Drupal-specific OpenSearch plugins for Firefox (and IE7, too!). They provide Drupal.org and api.drupal.org search integration in browsers supporting the OpenSearch search plugin protocol.
They are useful when searching for Drupal API routines or other Drupal development subjects. Install them as you would any other OpenSearch plugin...

MyBlogLog for Drupal 4.7

I've created a simple MyBlogLog module for Drupal 4.7. This module provides the following features:

  • Inserts the MyBlogLog tracking javascript into generated pages - no need to hand-edit your template's page.tpl.php file, or manually create a block to inject the tracking javascript.
  • Provides the "Recent Reader" widget block
    (includes configuration options - color, width, # rows, etc.)
  • Disable visitor tracking for Administrators and other users on a per-role basis (prevent skewed stats due to admin or other roles' visits.)


... and more

Syndicate content