Can I remove the subject field from post new comment form?
tom611 - September 6, 2006 - 03:52
I'd like to remove the "subject:" field for posting new drupal comments. It's an optional field, but it displays the truncated body if it is left blank. I just don't have any need to display a subject for comments. Thanks.

Yes
/admin/comment/configure
Look in "posting settings"
--
Anton
New to Drupal? | Forum posting tips | Troubleshooting FAQ
Not the solution
Unfortunately I don't believe that's what the poster was looking for. At any rate it's not what I'm looking for ;)
I would much prefer that comments inherit the subject from the parent node by default, but still possibly allow the user to change it. So simply, when posting a comment, just insert "re: " + $node_subject, or something like that. Having a different subject for each comment is just contrary to what most people expect from forum or forum-like software. I find it INCREDIBLY annoying lol.
I would rather be able to do this within a template instead of changing core code.
Steel Rat
Drupal Site: RPGMapShare.com
Inheriting subjects
I disagree :)
It sounded like they wanted to remove the subject line altogether.
True :)
I agree, inheriting but still letting the commenter change it would be the best way of doing it for just about everyone.
I don't think this is a template (ie theme) level problem. Solving it without altering core would really be a module level solution IMO.
The current bit of functionality seems to be here:
http://api.drupal.org/api/4.7/function/comment_form
<?phpif (variable_get('comment_subject_field', 1) == 1) {
$form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => $edit['subject']);
}
?>
The solution would probably be writing a module that uses http://api.drupal.org/api/4.7/function/hook_form_alter to prepopulate that form field.
Or course, a better longterm solution would be to create a patch against the core comment module that implements this and get it committed to core for Drupal 5.1/6.0 (whatever the version after next is called).
--
Anton
New to Drupal? | Forum posting tips | Troubleshooting FAQ
Au contraire
Correct, which the admin setting doesn't do. It only prevents them from entering a subject of their own. :) I know, I tried :(
I found another post which does offer a theme template alternative, by editing the comment.tpl.php. I don't have the link to that post, unfortunately, that was a week ago. I used that information and successfully removed the subject from displaying on comments. Works like a charm.
Steel Rat
Drupal Site: RPGMapShare.com
themeing issue
No need to have specifics on the comment forms. The answer is to edit the PHP in your comment.tpl.php file (found in yoursite.com/themes/yourtheme/) to make the comment node look just the way you want. I found the that contained my comment subject line and just deleted the whole thing. If you are new to editing theme template files then know that any of the theme PHP files can be changed to move elements around or assign different CSS classes as you wish.
Good luck.
just deleting the whole
just deleting the whole comment subject may not be the right way to go. The subject is used as a page anchor when entering the page from certain aspects. If it works for you, that's great.
Steel Rat
Drupal Site: RPGMapShare.com
So maybe including the
So maybe including the subject field in the tpl file but in a way this is not visible? That can be done. Then disabling the custom subject field in the cms would mean that the anchor is preserved and we get the apparent absence of the subject field on display. Am I thinking on the right track?
That's pretty much what I've
That's pretty much what I've already done based on another thread. A date/time stamp is used in place of the subject as the comment page anchor. It makes for a much cleaner look to the comment listing.
Steel Rat
Drupal Site: RPGMapShare.com
Can you point to that
Can you point to that thread, or possibly give directions on how you did this? I'd love to do this, especially for my forums.
this is how i hide the
this is how i hide the subject text but still keeping the anchor:
replace
<?php print $title; ?>with
<span style="display: none;"><?php print $title; ?></span>in the comment.tpl.php file
This didn't work for me in
This didn't work for me in D6. :(
I instead gave that span tag a class of "comment-subject" and referred to it in my theme's style.css file giving it the "display: none;". That worked for me.
Could you elaborate?
Could you elaborate on how you made that work in D6? I'm a newbie to editing css and php files, but I can follow directions if they're specific enough. I also tried just adding the snippet mentioned above and wasn't able to get it to work in D6 so wanted to try your solution.
In my comment.tpl.php file
In my comment.tpl.php file (if you don't have one create one), I put this:
<span class="comment-subject"><?php print $title ?></span>I just put a span tag of comment-subject around the comment's title. Find your
<?php print $title ?>tag and put my code around it.Then I went into my theme's .css file, and created this span tag there as well:
.comment-subject {display: none;
}
Technically you can name "comment-subject" to anything you want but I chose that to help me remember what it is for. :P It should probably be an ID instead of a class tag but since a comment title shows up for each comment(s) I wasn't sure.
I also want to hide the
I also want to hide the subject (v6) and tried your code Fayna, but for some reason it didn't work.
I am updating a custom theme in \sites\all\themes\tania and followed your instructions. But I suspect there is something else I need to do as I tried some other simple changes and they didn't seem to be reflected on my site. Do I need to refresh something?
Sorry, I'm new to the Drupal scene (would also like to modify the author date/time - to left align, change some of the text). Any help would be greatly appreciated.
Easy hiding of title
I was finally able to get this to work a while back. I checked my notes. All I did was to remove the following from comment.tpl.php
<?phpprint $title
?>
Drupalot.com - ask & answer Drupal questions
Needed?
Steel Rat above mentioned
There seems to be a few ways to do it (ie. I've come across various snippets) but the real problem I have is that any changes I made to the comment.tpl.php doesn't seem to have any effect what so ever - am I modifyingin the wrong place? - need to refresh something??
Sorted
A classic gotcha (http://drupal.org/node/238812#comment-792683)
I forgot to clear the cache!
I found the the code suggestion of xtedx was the only one that worked for me (even works in 6.2).
drupalot, I didn't remove it as you suggested as I was worried it would play havic with the recent comments block? (actually I not sure at all on that). Still thanks for your help - it was appreciated.
Congrats
No problem. Glad you got it working. I may try xtedx solution as well, as there are some weaknesses to the approach I took. Best!
Drupalot.com - ask & answer Drupal questions
This worked for Drupal 5.9
xtedx's post on May 16, 2007 - 07:39
this is how i hide the subject text but still keeping the anchor...
Worked fine for me! Thanks