4

When I created a content type, I chose to keep the Comments hidden. Now I have many posts of that content-type and I want to open the comments, which I did by editing the content type, but it did not open comments of any posts of that content-type.

How do I open comments on all the posts of a content type at once?

How do I remove that little help box under comments text area?

4

You'll have to edit your existing content and open the comments manually. If you have a lot of content you can probably do it directly in the database.

To remove the "help box" you can change the text format to "plain text" for the "comment body" field. If you want to keep the HTML option you can use a hook_form_alter() function to remove the text.

Better Formats Module might also do the trick.

  • In the database, I changed comment=2 for all the records of the content-type, but it did not take effect, I still see comment closed of all those posts in Drupal. – AKR Sep 25 '11 at 17:05
  • interesting, maybe node_revision has to change as well?. When you open the comments in the UI it works, right? If you have a lot of nodes you could look into VBO (Views Bulk Operation) – uwe Sep 25 '11 at 18:11
  • Yes, I had to update node_revision table as well. In order to update 'comment' field of this table, it required an SQL statement using 'inner join' clause along with 'node' table since this table does not have 'type' field. – AKR Sep 30 '11 at 3:22
5

Or directly into the database with :

UPDATE `node` 
SET comment = 2 
WHERE comment = 1

and

UPDATE `node_revision` 
SET comment = 2 
WHERE comment = 1

Where : Whether comments are allowed on this node: 0 = no, 1 = closed (read only), 2 = open (read/write).

4

To enable comments you should use Views Bulk Operations. It allows you to define operations to be executed against any view result.

You have to write a custom Rules action, but it will definitely be worth your time.

preconfigured views bulk operations

1

In Drupal 7, you can run following code using Devel Module

$num_updated = db_update('node_revision')  
  ->fields(array(
    'comment' => 2,
  ))
  ->condition('comment',1)
  ->execute();

echo "node revision table updated count: ".$num_updated ."," ;

$num_updated = db_update('node')  
  ->fields(array(
    'comment' => 2,

  ))
  ->condition('comment',1)
  ->execute();

echo "node table updated count: ".$num_updated ;
1

For Drupal 7, you need to enable comments in both node and node_revision tables. Use this query UPDATE node as n LEFT JOIN node_revision as nr ON nr.nid=n.nid AND nr.vid=n.vid SET n.comment = 2, nr.comment = 2 WHERE n.type = 'article'.

1

Adding node_type condition as following:

db_update("node")
->fields(array(
  'comment' => 2,
  ))
->condition("type", "node_type", "=")
->execute();

I can run the above with drush scr filename.php

Alternatively I could update with SQL query:

UPDATE node as n LEFT JOIN node_revision as nr ON nr.nid=n.nid AND nr.vid=n.vid 
SET n.comment = 2, nr.comment = 2 WHERE n.type = 'notes';
  • Good solution i sorted out my issue with this suggestion Thanks – Fawwad May 18 '16 at 7:40
0

Very easy to update comment for drupal node

simply run two query

  1. in node table

    UPDATE 'node' SET 'comment' = '2' WHERE TYPE = ''
    
  2. UPDATE node_revision  SET `comment` = '2' WHERE  nid in(select nid from node where type='rss_feed')
    

    should be update in both table revision and node.

0

Just Run this Query in devel/php environment to enable comments for all existing content.


$num_updated = db_update('node')
->fields(array(
  'comment' => 2,
))
  ->condition('type', 'CONTENT_TYPE', '=')
  ->execute();

$subquery = db_select('node');
$subquery->addField('node', 'nid');
$subquery->condition('node.type', 'CONTENT_TYPE', '=');
$num_updated1 = db_update('node_revision')
  ->fields(array('comment' => '2',))
  ->condition ('node_revision.nid', $subquery, 'IN')
  ->execute();

protected by kiamlaluno Sep 9 '13 at 21:05

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.