Just wondering if it is possible to have the nodecomments subject automatically with RE [count]: in each thread.

Comments

adamh’s picture

I've used http://drupal.org/project/auto_nodetitle to set subject automatically

summit’s picture

Hi Adam,

How did you do this exactly please? Thanks for sharing!

EDIT: I found the comment re: module: www.drupal.org/project/comment_subject
But the url to add RE: for nodecomment is node/add/comment/number

I want to use this code in nodecomment. Can anybody help with this please?

<?php
// $Id: comment_subject.module,v 1.3.2.5 2008/02/22 09:27:27 ahoeben Exp $

/**
 * Implementation of hook_form_alter().
 */
function nodecomment_subject_form_alter($form_id, &$form) {
  if ($form_id == 'nodecomment_form' && $form['subject']['#default_value']=='') {
    switch (arg(0)) {
      case 'node':
        $node = node_load(array('nid' => arg(1)));
        $subject = $node->title;
        break;
      case 'comment':
        if (arg(1)=='reply') {
          if (is_numeric(arg(3))) {
            $comment = _nodecomment_load(arg(3));
            $subject = $comment->subject;
          } else {
            $node = node_load(arg(2));
            $subject = $node->title;
          }
        } else if (arg(1)=='edit' && is_numeric(arg(2))) {
          $comment = _nodecomment_load(arg(2));
          $subject = $comment->subject;
        }
        break;
    }
    if (!preg_match('/^' . preg_quote(t('Re:')) . '/i', $subject))
      $subject = t('Re:') . ' ' . $subject;

    if (variable_get('nodecomment_subject_field', 1) == 1) {
      $form['subject']['#default_value'] = $subject;
    } else {
      // comment subject disabled in comment settings
      $form['subject'] = array('#type' => 'hidden', '#default_value' => $subject);
    }
  }

}

?>

Thanks a lot in advance for helping with this!
greetings,
Martijn

maedi’s picture

Status: Active » Closed (won't fix)

You can't use 'comment' modules with nodecomments. The Auto Nodetitle module uses Tokens and should be able to do all this for you.