Here is a module that can come in handy in certain cases.
Say you have a site and want to delete all content in it.
Reasons are:
- This is a test site that the client was using for a period of time, and they must clean it up before starting with real data.
- You are testing something that creates a lot of nodes (e.g. aggregator), and want to do it over and over again.
- You created a site in the past and want to replicate it again, but with new content.
The traditional way of doing this is to go into administer -> content then select all the nodes and delete them. This works if you have a handful of nodes only. If you have hundreds or thousands of nodes, then it is not a practical solution.
Another option is to directly delete the nodes from the node table in the database. This does not work properly, since there are also comments, and many tables for add on modules that needs to be cleaned.
So, my solution was to write this small module to delete all content programmatically.
I am attaching two files, one for 4.6 and the other for 4.7.
Instructions
Download the module for your Drupal version below, copy them to your modules directory, enable the module, then visit http://example.com/admin/node/deleteall
Update
The module is now updated for Drupal 5.x, and lives in the Drupal repository. It also provides an option to delete all users. See the Delete all project.
Attachment | Size |
---|---|
deleteall.4.6.module | 909 bytes |
deleteall.4.7.module | 878 bytes |
Comments
Visitor (not verified)
massdelete
Wed, 2006/09/27 - 22:53I think the massdelete.module does this already.
Visitor (not verified)
Cannot download
Thu, 2006/09/28 - 00:27Thanks for this module, great idea!
But I can't download the attachements, I get a 403 error message (Forbidden).
Khalid
Should be OK now
Thu, 2006/09/28 - 09:58Thanks for notifying me about this.
Should work now.
--
2bits -- Drupal and Backdrop CMS consulting
Visitor (not verified)
HI, This sounds like a great
Mon, 2007/01/01 - 22:06HI,
This sounds like a great module; how do in activate it? i created the file and put in modules and activated it but cant find anyplace where i can have it delete all nodes.
thnx
Khalid
Added
Mon, 2007/01/01 - 23:22I added instructions above on how to use it.
--
2bits -- Drupal and Backdrop CMS consulting
Visitor (not verified)
Hi, thnx for the
Tue, 2007/01/02 - 05:19Hi,
thnx for the instructions; when i activate delete in my modules as an administrator and than go to the path for node/deletall, i get the content page where i can mark nodes and delete one by one [this is the same as just going to the content page in admin]; am i missing a step here to get your script to work?
thnx
Khalid
Not enabled
Tue, 2007/01/02 - 11:22It means that this module is not properly enabled then, or the menu cache needs to be refreshed.
Enable it, then go and visit /admin/menu to clear the menu cache, then go and visit /admin/node/deleteall.
--
2bits -- Drupal and Backdrop CMS consulting
Visitor (not verified)
deleteall 5.4
Fri, 2007/12/07 - 04:25Hi,
Can you please submit a Drupal 5 version of this module?
Thanks you!
Greetings,
Martijn
Khalid
Now for 5.x
Sat, 2007/12/22 - 22:40It is now available for 5.x. See updates above.
--
2bits -- Drupal and Backdrop CMS consulting