By tomski777 on
Is it possible to disable & hide the preview button for all nodes?
I'm building a single user brochure site in drupal 4.6 & the preview button (and following actions) confuses my "very base level understanding" client. With lots of other form elements I've simply used .css to hide some things though the preview button doesn't have a reference...
Ta for any help :)
Comments
The only way you're going to
The only way you're going to manage to do that in 4.6 is to actually hack node.module and remove the preview button. You may need to do the same in comment module, and anywhere else you find preview to be an issue.
in 4.7 you could probably theme the node form and hide the rendering of the button, but that isn't possible in 4.6.
-- Merlin
[Point the finger: Assign Blame!]
[Read my writing: ehalseymiles.com]
-- Merlin
[Read my writing: ehalseymiles.com]
[Read my Coding blog: Angry Donuts]
Cheers fro ya input
Cheers fro ya input Merlin.
I was hoping to avoid a hack of node.module - oh well!
><>tomskii
><>www.mutinyarts.co.uk
Theme away your preview troubles
For 4.7, I just did this in my form theme function and it worked. Bye bye preview!
Thanks jmanico - At last the
Thanks jmanico - At last the holy grail!!! :)
Will undo some nasty hacks on old sites...
tom
><>tomskii
><>www.theanthillsocial.co.uk
disable preview button
I am using drupal5.
add the following code to template.php
function phptemplate_node_form($form) { //only for CCK form, invalid for account
//print path_to_theme().'/'.$form['type']['#value'].'_form.tpl.php'; die;
if(file_exists(path_to_theme().'/'.$form['type']['#value'].'_form.tpl.php')) {
return _phptemplate_callback($form['type']['#value'].'_form', array('user' => $user, 'form' => $form));
}
}
Say the content type of your CCK form is test.
in test_form.tpl.php
add
$form['preview']="" ;
print drupal_render($form);
Hope it helps.
In the case of form_alter
In the case of form_alter (D5) simply do this:
untested for D6
Fourth Wall Media
Toronto, Canada
Drupal 6 Hack
Here's a dirty hack to hide the preview button for all content types in Drupal 6. Comment this block of code out in your modules/node/node.pages.inc file:
There must be a slick way to simply remove this ['preview'] element from the $form['buttons'] array using a module. It would be nice to not hack the core like this :) But my client isn't paying for slick, just DONE!
Drupal 6 Module
Ok, I felt bad and learned how to make this into a nice module. It adds a check box in each content type form in the Workflow section to hide preview for node editing forms of this content type.
hide_preview.info
hide_preview.module
Kudos :)
Hey thanks for this little module, which I came accross after quite a bit of searching and by pure chance... could this be added to modules ?
It may be a small module but definitely a needed one !
Again, thanks :D
Edit : Just have a little problem to install this, I saved both files above upoladed to a newly hide_preview folder in modules/ and went to admin/build/modules but Hide Preview doesn't appear.
I thought it was because of the closing ?> (which I removed, it seems .module files don't have closing ?> but changed nothing).
Where did I go wrong ?
This module worked fine for
This module worked fine for me. Although, when I first saved the .info and .module files above, I noticed they were actually saved as .info.txt and .module.txt. I'm not sure if that's your poblem or not? I had to remove the .txt part from the file name.
Besides that, I copied and pasted the code into a blank notepad file, saved each as hide_preview.info and hide_preview.module. Then created a folder in modules called hide_preview. Copied both files into that folder. Went to modules and enabled the Hide Preview module. Didn't see any permissions that needed to be enabled and it worked properly.
Unfortunately, after doing all of this, I learned this wasn't what I was really looking for. I was wanting to disbale the preview button for comments, not for editing nodes.
worked fine:)))
worked fine....thaaaaanks man :))))))))))
Thanks for sharing
Thanks for sharing kevinhammer!
Thank you!
It worked like a charm! Why did not you publish it as a module?
This worked for me in Drupal 6
Works like a charm
Thank you for the tip webthingee!
I used it for my custom node only :
Solution for Drupal 6
For a detailed explanation of how to solve this cleanly in Drupal 6, check out How to remove or hide the 'Preview' button in Drupal 6. Suggestions similar to above (using hook_form_alter), but also using the unset() function as well as how to target specific node types based on form IDs. Hope that helps the next person that comes across this page!
None of the suggested .module
I was trying to remove the Preview button on all Comment forms but none of the suggested .module files above worked.
Heres one that did (note: you need to add your custom module name to the beginning of the form_alter function):
Thanks for the pointer in the
Thanks for the pointer in the right direction... Maybe you were using a different version of Drupal... I had to alter your line from:
unset($form['preview']);
to
unset($form['buttons']['preview']);
I'm also using it for the node form not comments
I've often called Google "gods homepage", now I call chatgpt "conversations with God."
I am always interested in paid work... Contact me through Online Business Builders
Module to remove the preview button!
The "Content Form Jammer" submodule (http://drupal.org/project/jammer) allows removing the preview button per content type.
Solution for Drupal 7
function mymodule_form_alter(&$form, ...) {
// disable preview for D7
if ($form['#node_edit_form']) {
unset($form['actions']['preview']);
}
}
Hiking up the Drupal learning developer curve