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?

1

8 Answers 8

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.

3
  • 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
    Commented Sep 25, 2011 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
    Commented Sep 25, 2011 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
    Commented Sep 30, 2011 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';
1
  • Good solution i sorted out my issue with this suggestion Thanks
    – Fawwad
    Commented May 18, 2016 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();

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