Drupal offers two options, both not really useful. The first is to let you always specify the subject of the comment, the second is to lock it to the first words in the comment.
What I'd like is to auto fill the subject field with "Re:" followed by the subject of the *node*. And then leave the user the possibility to type a new title entirely or leave it as it is.
For example, at line 1462 of the comment module: $form .= form_textfield(t('Subject'), 'subject', $edit['subject'] ? $edit['subject'] : variable_get('anonymous', 'Anonymous') , 60, 64);
This defaults the subject field to the anonymous name. I just need to know the exact code to replace that with the node title and add a "Re:" before it.
Can someone help me?
-HRose / Abalieno
I made a little step forward on my own: $form .= form_textfield(t('Subject'), 'subject', $edit['subject'] ? $edit['subject'] : 'Re: '. $node->title, 60, 64);
This correctly displays "Re:" But it seems that the function isn't aware of the node array. Can someone help how to import it so I can input the title on that line?
The syntax seems correct but the form shows nothing because I believe the definition of the node is external.
Op zaterdag 10 september 2005 13:18, schreef Abalieno:
$form .= form_textfield(t('Subject'), 'subject', $edit['subject'] ? $edit['subject'] : 'Re: '. $node->title, 60, 64);
This should be $form .= form_textfield(t('Subject'), 'subject', $edit['subject'] ? $edit['subject'] : t('Re: '). $node->title, 60, 64);
And AFAIK there is a 'nid' ni the comment oject A node_load() with that nid will give you the parent node object.
Regards, Bèr
It works :)
After many attempts to get it right this is the code I used:
// subject field: if (variable_get('comment_subject_field', 1)) { $node = node_load(array('nid' => $edit['nid'])); $form .= form_textfield(t('Subject'), 'subject', $edit['subject'] ? $edit['subject'] : t('Re: '). $node->title, 60, 64); }
It works correctly, the syntax is okay too?
----- Original Message ----- From: "Bèr Kessels" berdrupal@tiscali.be To: drupal-support@drupal.org Sent: Saturday, September 10, 2005 2:47 PM Subject: Re: [drupal-support] Locking comment subject to the node title
Op zaterdag 10 september 2005 13:18, schreef Abalieno:
$form .= form_textfield(t('Subject'), 'subject', $edit['subject'] ? $edit['subject'] : 'Re: '. $node->title, 60, 64);
This should be $form .= form_textfield(t('Subject'), 'subject', $edit['subject'] ? $edit['subject'] : t('Re: '). $node->title, 60, 64);
And AFAIK there is a 'nid' ni the comment oject A node_load() with that nid will give you the parent node object.