Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By hf on
Hi,
Is there a way to totally turn off the preview option from comments? At the moment it is on optional, but I would like to remove the button totally.
Thanks,
hf
Comments
yep visit
admin/comment/configure
and set your preference
Preview comment:
Optional
Required
EDIT: Ooops....I really should read the question better>disregard the answer.
wellsy
orchidsonline.com.au
do so in the theme
Once you have made it optional, it seems like there ought to be a way to use the "display: none" line in your theme style sheet to make the button disappear.
Modify your theme template and the Comment module
If you are upto editing PHP, go to the modules directory and find the comment.module, edit the line 1419 and disable the creation of the preview button. Remember that anything you tweak in the modules' code will be erased whenever you upgrade your Drupal installation and replace that file with an updated one... Keep a record of your changes so that you can implement them again once you upgrade (in future).
You can customise the look and features of your comment view by editing the comment specific template found in your Theme's folder (it's called comment.tpl.php).
Curious: On a different note, it does nto harm you to have the preview button as an option, why go through all this to remove a edit level option?
-----
iDonny - Web CMS Development, Design, and Web Marketing Advice
Thanks
iDonny,
Great job, thanks a lot!
I have tried iDonny's way (modifying comment.module), and it worked perfectly. I did not have to change the theme template (I am using the "pushbutton" template).
For your question: I have examined statistics, and I noticed, that lot of visitors go into the comments, but do not send in any comment. Since my page is quite simple, and I have just a few comments, I thought I make it simple and obvious: just push the button and the comment is done, users cannot go wrong. Whoever is registered still can change the comment anyway.
Thanks for everybody who answered!
hf
On Drupal 5.x
Create a file called comment-form.tpl.php in your theme directory and put the following in it:
For the record and clarity
For the record and clarity sake for people visiting this by search (as I just did) to make the above work,
Also add this to your template.php :
Tested for 5.x
Try this here
Ops, sorry: This applies for drupal 5 not 4
Copy / paste this into your template.php and replace "yourthemename" with your theme name :)
Make sure you don't copy paste the
tags
hmmm
This threw an error for me, it looks liked it balked at the "-" in my theme's filename. Perhaps dashes in theme names are not allowed? Never ran into trouble with it before though...
For now, I just added this to my stylesheet, which of course simply makes the button disappear from view:
#edit-preview
{
display: none;
}
~drOOb
For now, I just added this
The better approach is to remove the button completely using Drupal theming or by modifying the comment.tpl.php file. "display:none" is not effective and I wouldn't recommend it. Anyone using something as simple as Firebug would be able to remove the styling and click the button.
Drupal 6....
Been playing around with this all night....
I got rid of line 1392 in comment.module...the line that reads something like....
For Drupal 6, this provides
For Drupal 6, this provides the 'Save' button instead of just 'Preview', i.e for guests attempting to leave comments (really annoying if you have captcha enabled, otherwise they have to enter the captcha for both the preview and the save after that):
comment.module
Is there not a setting in
Is there not a setting in the admin page? or do we have to modify the code?
Edit your comment preferences
It looks like comment preferences are edited on a per-content-type basis in Drupal 6.x. For example, if you want to change the settings for comments on blogs, navigate to Administer -> Content Types. On the "Blog Entry" row, click "edit" and scroll down to select "Comment Settings". There you can set preview to optional. It still won't fix having to enter a CAPTCHA for both preview and save, but at least a user can skip the preview.
FYI: This info is derived from a reply by simon_ives on http://drupal.org/node/23703 (dated February 28, 2008 - 23:41). I've tried it and it seems to be a reasonable compromise between forcing users to enter two CAPTCHAs and manually updating comment.module.
For Drupal 6
Modify line 1389 in the file comment.module:
To:
and comment the line 1393
Apply this in template.php
Is there a way to use this method in template.php so you dont need to hack the core commenting module?
Drupal 5
SomeGirl's method worked perfectly. I'm using Drupal 5, and the line was nearly identical. The line number was different, but I just did a text search to find it. After commenting out this line, everything works perfectly and the "Preview comment" button is gone.
I simply commented out this line in comment.module:
please don't hack the core
please don't hack the core modules. if you're trying the tip from comment http://drupal.org/node/57842#comment-815045, and having problems with your theme name use 'phptemplate' instead of your theme name in template.php like
You can do it through admin...
I tried the above and it didn't work, so then I re-read this thread and noticed the comment from dbc60 http://drupal.org/node/57842#comment-998037
So much easier to just edit comment settings at admin/content/node-type/forum.
Just wanted to bring attention to this in case someone glossed over it like I did...
What is the correct code for Version 6
A few people here are getting confused about what the post is trying to achieve, eg: to TURN OFF preview altogether, not just make it optional. You cannot achieve this with admin settings.
The phptemplate code above does not work for V6 - any ideas ?
Correct way to do it in Drupal 6
You need to create your own little module that implements the hook_form_alter function. This allows you to change the form and all it's elements without hacking core.
This is the code that goes into your MODULE_NAME.module file:
It basically removes the button from the form array before the form is rendered. You could also use this to modify other elements of the comment form.
Thanks for the snippet. I put
Thanks for the snippet. I put into a module and placed it with the jammer module, and it works fine.
Here is a link to the relevant issue for the jammer module: http://drupal.org/node/517240#comment-1889094
The alternative Drupal 6 way...
Further to netsensei's comment, you can also you the hook_form_FORM_ID_alter in your module if you prefer :
Which goes into your MODULENAME.module file.
http://www.atomicant.co.uk
I have tested this code. It
I have tested this code. It works perfectly. Thanks!
Hi You must go to in content
Hi
You must go to in content type of your section and edit the configuration in address :admin/content/types
for example : if you want to turn off preview for forums you can go to management -> content type -> forum -> edit and turn off the preview comment from comment settings
also for other sections you can do this as well to turning off the preview ...
I agree with drupalcms.ir. We
I agree with drupalcms.ir.
We should look for the settings options provided by each module as much as possible before doing custom code hacking.
no way to disable preview
Under content type/edit you can only set preview comment to optional or required - you can't turn it off all together
CSS hack
It's not a real solution.
Add these lines in your theme's stylesheet.
#edit-preview{
display: none;
}
EDIT....
!!!Sorry I hadn't seen previous comment !!!
This trick has been suggested before.
Subscribing..still no setting
Subscribing..still no setting to remove preview in comment.module itself?
I prefer not to change theme or modules because of not able to do a clean update then..
greetings, Martijn
steps to disable preview
Please click http://localhost/sample/?q=admin/content/node-settings
or access Administer-->ContentManagement-->PostSettings.
Hope you can disable preview.
DRUPAL 6: Hide "Preview" button for comment form
in template.php
this works ...
Module to remove PREVIEW button ?
Hi,
I don't want to hack because i will forget it during updates, so do you know if there is now a module that removes the preview button for comments ?
Thanks.
Try out the Jammer module:
Try out the Jammer module: http://drupal.org/project/jammer
How to disable comment preview for Drupal 5 in 2010
Hi,
In case someone is still looking for this, I just disabled comment preview for Drupal 5 by doing what has been written by 2 nice guys on this page:
On Drupal 5.x
Posted by mr.j on January 18, 2008 at 6:40am
Create a file called comment-form.tpl.php in your theme directory and put the following in it:
* reply
For the record and clarity
Posted by Paintbox on February 18, 2008 at 9:57am
For the record and clarity sake for people visiting this by search (as I just did) to make the above work,
Also add this to your template.php :
function phptemplate_comment_form($form) {
return _phptemplate_callback('comment-form', array('form' => $form));
}
Tested for 5.x
And it works (perfect for me as i am sure that i won't update the template).
For Drupal 6 the easiest solution is to use JAMMER module, but it seems that Jammer doesn't allow to disable PREVIEW for comments on Drupal 5, why ?!
Thanks.
Configure Comment settings tied with content types
By default, Drupal is configured to force anonymous users to preview their comments before posting them. To enable users to post without previewing their comment, you might think you'd access:
Administer > Content Management > Content Settings > Post Settings
or
Administer > Comments > Configure
But it doesn't work this way
In Drupal 6, the comment preview settings are tied to each content type. Visit:
Administer > Content Management > Content Types
Refer to this url http://www.99tutes.com/content/drupal-disable-required-comment-preview.html for more details
comment by mistake
comment by mistake
In Drupal 7...
In Drupal 7, go to content type with the comments enabled. Look under Comment Settings.
How to turn off or hide the Preview button in comments
Note that the form has to actions (preview and submit)
To turn off the preview button
$form['actions']['preview']['#access'] = FALSE;
To turn on the Save button in order to by pass the Perview button
$form['actions']['submit']['#access'] = TRUE;
$form['actions']['preview']['#access'] = FALSE;
That should take care of it. Also, I have seen some posting asking how to change the submit button name and I think here is how you can change the name of the submit button
$form['actions']['submit']['#value'] = "Post Comment";
All these has to be done in your custom comment.module so you will not be affected by Drupal update.
Solution for D7 - remove the comment preview button
Path: /admin/structure/types/manage/[content type] -> comment settings -> Preview comment -> disabled -> save content type setting.
Regs,
Francis
SOLVED for drupal 7.x
Here i post the solution for me:
hook_form_comment_form_alter(&$form, $form_state) {
unset($form['actions']['preview']);
}
Drupal 8
(as this remains the top Google result for disable/turn off comment preview)
You can do it through the UI on a field-by-field basis - specifically you:
- Edit the content type the comment is attached to (NOT the comment type)
- Go to the Manage Fields tab, then edit the comment field
- Scroll down the bottom of the Edit tab for the 'Preview comment' options - there are radio buttons for Disabled, Optional and Required.
Thank you! A perfect solution
Thank you! A perfect solution in a weird drupal thread, but you are right, Google rated it as the best relevant page even when 8 is an actual version.