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

styro - September 6, 2006 - 04:13

/admin/comment/configure

Look in "posting settings"

--
Anton
New to Drupal? | Forum posting tips | Troubleshooting FAQ

Not the solution

Steel Rat - September 24, 2006 - 00:10

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

styro - September 24, 2006 - 02:23

Unfortunately I don't believe that's what the poster was looking for.

I disagree :)

It sounded like they wanted to remove the subject line altogether.

At any rate it's not what I'm looking for ;)

True :)

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 agree, inheriting but still letting the commenter change it would be the best way of doing it for just about everyone.

I would rather be able to do this within a template instead of changing core code.

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

<?php
 
if (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

Steel Rat - September 28, 2006 - 19:16

I disagree :)

It sounded like they wanted to remove the subject line altogether.

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

seaneffel - October 1, 2006 - 18:21

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

Steel Rat - October 2, 2006 - 14:28

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

seaneffel - October 2, 2006 - 20:50

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

Steel Rat - October 5, 2006 - 13:35

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

jinks - December 14, 2006 - 00:53

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

xtedx - May 16, 2007 - 07:39

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

Fayna - May 17, 2008 - 02:56

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?

fumbling - June 15, 2008 - 05:13

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

Fayna - June 25, 2008 - 17:04

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

tanma - July 29, 2008 - 06:47

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

fumbling - July 29, 2008 - 16:46

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

<?php
print $title
?>

Drupalot.com - ask & answer Drupal questions

Needed?

tanma - July 30, 2008 - 05:40

Steel Rat above mentioned

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.

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

tanma - July 31, 2008 - 11:34

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

fumbling - August 1, 2008 - 16:19

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

robclay - August 11, 2008 - 05:29

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

 
 

Drupal is a registered trademark of Dries Buytaert.