You are here

Drupal tips

Drupal 6 to 7 upgrades

The Select builder adds a LOT of overhead. You should not use it unless you need one of the things it offers: Dynamic query structure, hook_query_alter, certain db-unportable features that don’t have a simpler version (random ordering, for instance), etc.
For the run of the mill SQL query, db_query() is several times faster than db_select(). If you need a limit query, db_query_range() is still there.

The "Support" module on Drupal

Some notes on configuring the module

  • Follow the online instructions, but also
    • set the support content type not to be on the front page
    • set the from email address to be do-not-reply@mydomain
    • Default sort: State/ascending
    • Secondary sort: Last update/descending
    • Modify the new and updated ticket email to be something like this:

Deleting large numbers of comments from Drupal

  • You can easily delete all comments with:
DELETE FROM comments;
  • The problem comes when there are good and bad comments, and you only want to get the bad comments. -The cleanest way is to delete all the rogue users first. That will set the UID on their comments to 0, so you can delete all their comments by running:
DELETE FROM comments WHERE uid=0;

Resources for creating a new drupal module

This is my quick reference of useful links
Module developer's guide:
Coding standards:
Doxygen and comment formatting conventions:
Apply for contributions CVS access:


Themeing CCK output in Drupal

There seem to be several ways of getting CCK fields into your node-typename-node.tpl.php file:

  • First using the _rendered variable which will give both the label and the content: <?php print $field_website_rendered; ?>
  • Second using 'view' which will just give the contents of the field:<?php print $field_website[0]['view']; ?>
  • Two methods recommended by Front End Drupal. First using 'safe': <?php print $node->field_website[0]['safe']; ?> seems to fail all the time

Class 'XMLWriter' not found

In a Red Hat or CentOS server installation, XMLwriter may not be enabled by default. To enable it, follow these steps:

# If you are using the base 5.1.6 php, then
yum -y install php-xml

#if you are using php 5.2 (from the centos 5 testing repo)
yum -y --enablerepo=c5-testing install php-xml

#restart apache
service httpd restart

Drupal and PHP 5.3

There are some problems with running Drupal on php 5.3. There are five kinds of solutions:

  1. Downgrade to php 5.2.6 (not possible in many situations)
  2. modify Drupal to change the error level reporting
  3. find the latest patches to fix the problems
  4. hack Drupal core or contrib yourself to fix the errors (Drupal 6 is already compliant, but not D5)
  5. put a timezone in your php.ini to get rid of timezone errors

Drupal 6

2. Modify Drupal's error reporting --already done for Drupal 6

3. Find patches

Website Releases via Subversion (SVN)

This article was originally posted at:
but this site now seems to be dead, so I have recovered it from and re-posted it.

If I am breaking any copyrights here, please let me know and I will remove it.

Note that Drupal now blocks any path containing "svn-base". See:

Planet Drupal links

Useful links to posts on Planet Drupal that I want to remember for later:
How To: Create a Drupal Calendar
33 Most Useful Domain Tools


Managing Acquia Drupal with dget, dsite and dsvn

#place to put dget scripts


#get dget suite and install it, editing if necessary

svn co $DGETDIR

#check out drupal core, contrib

dsvn checkout

#use dsite checkout if no need to commit from this site
#and optionally, the Acquia distribution (ignore any warning at the end)

dsvn checkout x x a6paths


Subscribe to RSS - Drupal tips