Skip to main content

Drupal 5.x

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).

Useful Drupal Administrative SQL Queries

Quite often, it is necessary to perform batch operations on a drupal-based site - operations on multiple users, or multiple nodes, for example, and the administrative interfaces don't support the desired operation.

I've put together a list of my favorite queries on this page. I'll update these as time permits.

Syndicate content