Preamble
Recently i decided to switch Drupal’s build in comment system to Disqus. Its seems to have a lot promising benefits for my current project SC2.FM, but there was one big problem on the migration. While disabling comments on newly created nodes was no problem ( Via the Content Type settings page ), i had ~26.000 nodes with the comment settings turned on and no way to disable the comment feature on all of them in a reasonable time frame.
After a small research it seems like there is no module for this task and no helpful knowledge on Google. So i’ll explain how you can easily turn off comments for existing nodes without editing them all by hand.
What is Drupal?
Drupal is an is a is a free and open source content management system (CMS) written in PHP and distributed under the GNU General Public License. It is used as a back-end system for at least 1% of all websites worldwide ranging from personal blogs to corporate, political, and government sites including whitehouse.gov and data.gov.uk - Wikipedia
What is Disqus?
Disqus is a global comment system that improves discussion on websites and connects conversations across the web - Disqus.com
Requirements
- Drupal 6.20 or higher
- A recent database backup
The Magic
It all came down to one little sql query. Please read the explanations below, before applying the query to your database!
AND BACK UP YOUR DATA FIRST !
UPDATE node SET comment = 0 WHERE type = "my_content_type"
The SET part
SET comment = 0
Means that all nodes will be set to “Comments disabled”. If you want “Read only” then replace the 0 with a 1. If you want “Read and Write” then use a 2 instead of the 0 here.
On the WHERE part you can specify for which content type you want to change the comment settings and possibly from what existing setting. The same logic as above applies : 0 for “Comments disabled”, 1 for “Read only” comments and 2 for “Read and Write”.
You need to replace the “my_content_type” with the machine readable name of the content type you want to change. You can find the name on the “Content Types” overview page.
For example
WHERE type = "my_content_type" AND comment = 2
Would only disable comments for all nodes of the type “my_content_type” which have the comment settings set to “Read and Write”.
With another WHERE argument this could also be used to disable comments or set the comments to read only on old posts.
Let me know in the comments if you have questions or suggestions.
Back to top