Drupal: How To Disable Comments For Nodes Of A Certain Type
It is necessary to disable comments for nodes of a specified type. There should not be any comment, link on the form for adding a comment etc. when the node viewing.
Solution
Comments settings are stored in a database individually for every node. And you can set general comments settings (default settings) on setting page for the required node type. However, these settings will be applied for new nodes only.Therefore there are 2 phases of comments disabling – for new nodes and for existing nodes.
Disable comments for new nodes
To disable commenting for new created nodes of the specified type, you should:
- Open settings page for this type of nodes (page, story or something other): admin/content/node-type/[node type]
- Open Comment settings
- Set Default comment setting parameter to Disabled
- Save settings
Disable comments for existing nodes
Alternatives
- Using SQL-snippet
- Using Mass Change module
Using SQL-snippet
To disable comments in already crated “story” nodes you should execute SQL-snippet:
UPDATE node SET comment = 0 WHERE type LIKE “story”;
Possible variants:
- comment = 2 – read and write comments
- comment = 1 – read comments only
- comment = 0 – comments disabled
Change “story” value to 2, 1 or 0.
Using Mass Change module
Install Mass Change module and you will be able to do mass change of node parameters including comments settings. Please do not forget to disable this module – there is no need to use it all the time!
Summary
SQL-snippet is a fast solution. Using of the module makes sense if you are going to make mass change to node parameters frequently.