20

Is it possible to remove the subject field on comment forms? I find it to be kind of useless and redundant, since the subject of the comment is usually the title of the article being read, at least for me anyway.

3 Answers 3

32

You can turn it off in the UI at admin/structure/types/manage/type-name with the "Allow comment title" checkbox:

enter image description here

2
  • 7
    Seems like they should rename "title" to "subject"... it would be less confusing. Thanks. Oct 1, 2012 at 22:20
  • In my case it is not possible to remove comment subject. Is it possible that there is a problem with other modules or after publishing some nodes this feature doesn't function? May 2, 2016 at 1:44
2

There I have found some solutions to this question.

Option 1:

How to disable comment titles in Drupal 7. This is so easy and good tutorial to simply hide the subject(title) of comment through user interface.

Option 2:

You can also use the hook_preprocess_comment() in template.php file of your current active theme. This is really cool snippet, you can also some other options ie. comment-reply, comment-delete or comment-edit etc.

function bartik_preprocess_comment(&$vars) {
  $vars['submitted'] = $vars['created'] . ' — ' . $vars['author'];
  switch( $vars['node']->type ){
    case 'macine-name-of-node-type':
      $vars['title'] =FALSE;
    break;
  }
}
-2
//get comment by node id
$comment->nid = $nid;
//get form by form name
$form = drupal_get_form('comment_form', $comment); 
//hide subject in form
hide($form['subject']);
//check comment form
print render($form);
2
  • I don't get it ... Jul 31, 2017 at 8:00
  • Hi Vivec, 4 lines of code are not really an answer. Can you explain where to place these lines? What function or hook? Jul 31, 2017 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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