i have a situation, where I want commenting enabled except for on one content type.
Ive enabled activity comments in my activity view, and get the comment form under all items.
However I need it gone or hidden for content type 1. but there for all other content types. I.e hidden when a user creates/updates a page, but there when a user creates/updates a story or blog etc.

Is this possible? How do i do this?

Thank you

Comments

Scott Reynolds’s picture

Probably only attainable via theming of the Field.

You can look into form alerting it as well.

pribeh’s picture

Follow the example in comment #12 of this thread http://drupal.org/node/602896 if you need more help.

Saeh’s picture

thanks, that post helps.

How do I filter activity template though, is there an id or something, where do i get it from

Scott Reynolds’s picture

hmm actually i would do this

function MY_MODULE_form_activity_comments_form_alter(&$form, $form_state) {
  $no_comments_node_types = array(
    'content_type_1',
  );
  $activity_record = db_fetch_object(db_query("SELECT * FROM {activity} WHERE aid = %d", $form['aid']['#value']));
  if ($activity_record->type == 'node') {
     $node_type = db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $activity_record->nid));
     if (in_array($node_type, $no_comments_node_types)) {
        $form['#access'] = FALSE;
     }
  }
}
pribeh’s picture

I presume that's more efficient than theming (hiding) the comments. I've just been displaying comments for only statuses, and not nodes, by using the following in the view-row.tpl:

<?php if ($fields['type']->content == "facebook_status"): ?>
<?php print $fields['comment_form']->content; ?>
<?php endif; ?>

I'll test the custom mod now.

Scott Reynolds’s picture

I presume that's more efficient than theming (hiding) the comments.

It won't speed up your site :-D, but yes. It avoids calling theme('form_element_type1') ... theme('last_form_element_type') and doing all that work.

Its cleaner as it doesn't require an extra .tpl.php. Template files are slow comparison.

Scott Reynolds’s picture

Status: Active » Fixed

Marking as fixed. Reopen if it doesn't work.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.