Email
Share
Sep 25 2009
Last update:

Drupal - Mass Delete Events

Filed under: Content Management Systems » Drupal,

Drupal - How to Mass Delete Events

Are you stuck with a gazillion recurring events? Want to clear out the calendar all at once? CWD shows you how...

 

Drupal - Delete All Events At Once

Use the following code to delete Drupal 4.7 event nodes (courtesy of kingandy) (please note this is PHP code):

$aquery= db_query("SELECT nid FROM {node} AS n WHERE n.type = '%s'",$contenttype);

 

if( db_num_rows($aquery) && user_access('administer nodes')) {

  while ($row = db_fetch_object($aquery))
    {
set_time_limit(5); // prevents server timeout
node_delete($row->nid);

  }

} else {

print "No entries found for node type $contenttype, or you do not have permission to modify nodes.";

}

Clearing out the Event Calendar

The above script clears out all event nodes. You may need to clear out your events tables as well to clear the repeat pattern, calendar map, etc.).

First, access your database (via phpMyAdmin). Then, simply execute the following SQL query:

TRUNCATE TABLE event; TRUNCATE TABLE event_repeat; TRUNCATE TABLE event_repeat_calendar_map; TRUNCATE TABLE event_repeat_nodes;

Voila Smiling It's also possible to run this within Drupal:

TRUNCATE TABLE {event}; TRUNCATE TABLE {event_repeat}; TRUNCATE TABLE {event_repeat_calendar_map}; TRUNCATE TABLE {event_repeat_nodes}; 

Post any questions below.

Mass Deleting Nodes in Drupal 5.x+

For versions of Drupal above 5.x, you can use the mass delete or delete all modules.

Your rating: None Average: 1.4 (23 votes)

Your rating: None Average: 1.4 (23 votes)

Select your preferred way to display the comments and click "Save settings" to activate your changes.

New event system

What Drupal needs is a reliable event management system. The Date + Calendar + CCK combination is a step in the right direction.

Drupal mass delete

That's good news that there's an option to mass delete content within Drupal. I have enjoyed the user-friendliness of Drupal as opposed to my last platform, which was a c-panel known as Magento. Drupal for sure helps me with my site.

The content of this field is kept private and will not be shown publicly.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.