How can I delete a homepage field from a comment form?
takaki - May 28, 2007 - 22:31
Hi
I would like to delete a homepage field in a comment form. There are 5 field in a comment; your name, email, homepage, subject, and comment. I just want to keep name, email, and comment.
I could erase subject field by changing the setting at the admin menu, but for homepage field, I suppose I need to modify a comment.module, but I am not sure how to edit it.
Any help would be greatly appreciated.
Thank you.
Takaki

Hi Takaki, As a default I
Hi Takaki,
As a default I think there are only 2 fields for comment: Subject and Body.
So obviously, you don't need to edit comment.module.
It seems you have may have module installed to configure the way people comment on your posts, which adds extra fields to the comments. Try to identify that module and configure it.
Hope this helped,
SabbeRubbish
Hi SabbeRubbish, Thank you
Hi SabbeRubbish,
Thank you for your help.
I should have said that this is for anonymous user. I set my drupal to accept a comment from
anonymous. Then the comment form include those fields I mentioned in my original post.
I have installed only one module which is muti-ping sites module and I do no think it is related to comment field.
Thank you.
Takaki
Long shot but I think it
Long shot but I think it should work
create a node-comment.tpl.php and test it to see if it over writes the default comment node then you can code the parts of the comments that you would like to appear
run a search on google for "node-comment.tpl.php"
see if that helps
Hi Somes, I suppose you
Hi Somes,
I suppose you meant this: http://drupal.org/project/nodecomment
Sounds like it can do what I want, but I am more lean towards editting a comment.module
because deleting one field from the comment form should not be that difficult.
Anyway, I will try this if there is no other way.
Thank you.
Takaki
=-=
Just a note that altering a core.module while possible, makes it a pain to upgrade or update, as all changes will need to be done again.
If you really want to remove this from the core comment module, I believe you can look for the form array. search the code using homepage as your search term, find the form array and comment it out, it may be in two places.
I agree with
I agree with VeryMisunderstood,
Don't change the core modules at any cost! It will make an upgrade not only time-consuming but very discouraging, which would make you not update and leave some security bugs and such in...
Anyway, overriding the template seems like the best shot to me, you can easily migrate and upgrade that code. Of course, you will have to do some coding and take a look at the form API, but the gain compared to editing the core module is great I think.
I though I had a solution at the beginning of this post, but I've lost it...
SabbeRubbish
Then I will look into
Then I will look into overriding the template approach.
Thank you all for your advice!
Takaki
just had another look at this
After reading you email again I think what your looking at doing is stopping the field from appearing at all in the "form" and not just removing it from the comment node
to do this I think you'll have to override the form API that outputs the form field I haven't tried anything like that
http://drupal.org/node/124849
ie edit the comment_form_alter
by the way how did you manage to enable the home page - you can disable it also, it doesnt appear on a virgin installation of 5
do let us know how you get on
Were you successful?
Takaki -
Were you able to remove the homepage field? If so, what approach did you use? Any details would be appreciated. I would like to do the same thing on one of my sites.
Thanks.
shifthappens, Sorry, I have
shifthappens,
Sorry, I have not cheked this thread for a long time... and I have not tried this.
Generic module to hide/remove form fields?
Once, in the last months, I've seen a generic module which gives a GUI to hook_form_alter to remove/hide fields but I don't remember it's name.
Please advise
Thanks in advance,
Amnon
-
Professional: Drupal Israel | Drupal Development & Consulting | בניית אתרים
Personal: Hitech Dolphin: Regain Simple Joy :)
Check formfilter
I've now found formfilter - it is a really great module and allows to remove hidden form fields and collapse extra definition below the form.
One way to do it
add the following to your template.php file
function phptemplate_comment_form($form) {return _phptemplate_callback('comment-form', array('form' => $form));
}
create a file called comment-form.tpl.php
<?php //comment-form.tpl.php
$form['homepage'] = null;
print drupal_render($form);
?>
This worked as needed.
This worked as needed. Thanks.
If using a version prior to 5.0...
Replace 'drupal_render' in line 4 of the comment-form.tpl.php with 'form_render'.
I incorporated this change on 4.7.6 with the above tweak, and it's working great.
Worked for me
Worked for me too, though I don't understand why it works.
Another way
Hi,
I managed to do this with a custom module, in the form_alter hook:
global $user;if (!$user->uid && $form_id == 'comment_form')
{
unset($form['homepage']);
}
I'm a bit of a PHP newbie so I don't know if this has any repercussions, but I think it's a bit cleaner than editing core module stuff.
What the module?
Takaki, i am searching the comment module with 5 field like you said. Can you give me about the name and download link ?
I get some problem when searching , the information that i get is not specific like i need. So i am being confused about what the module name.
Thanks
I do that with css
I do that with css :
#edit-homepage-wrapper{
display:none;
}
it works form me!