By nasium on
Is there a way that I can remove the preview button in my custom node?
When I send the user to the add screen, i use this function:
function weblinks_form_weblink_user() {
drupal_goto("node/add/weblinks", $query = "ref=user");
}
The only way I can think of is hacking the core code...
please help...
Comments
I was looking for the same thing and found..
hi nasium,
I don't know if you're still interested in this - I found your post because I was looking for the same thing and found it from here: http://drupal.org/node/62319
First I was a bit scared of going for my (first) own 'module' - but it is really not that dramatic.. For drupal 5.x you just need the .module and the .info file and throw the function (as descriped on http://drupal.org/node/62319) in that .module-file and that's basically it..
I added a form_id-check to control which form has a preview button and which form not.. - ..the 'echo' is there to find out what form_id I have on a specific page - here's my code for hiding the preview button from the comments and from mycontenttype:
..hope it helps..
greetings, t..
___________________________
my pictures: www.bilderbook.org
___________________________
Thankyou
Thankyou for leaving this how-to , it worked first time.
..thank you for the thank
..thank you for the thank you! ..glad to hear it helped..:]
greetz, t..
___________________________
my pictures: www.bilderbook.org
___________________________
Can't figure it out
Hi Tille
thanks for the info on how to deal with the pesky Preview button. However, I can't get it to work - I've created a nopreview.module (with nothing but the your code) and a nopreview.info file and placed them in a "nopreview" folder with my other modules but it's not showing up in the module list? What am I doing wrong.
Thanks very much for any help and cheerio
Ole
Can't hide Preview button - module showing, but not working
Hi,
well, here's what I added for the module:
and the info file:
Uploaded in a folder called "nopreview" to sites/all/modules.
I enabled it on the modules page. Then tried to create those content-types - but preview button still shows.
then considered maybe it was the ccontributed theme I was using - so switched to Garland. Still didn't hide preview button.
Does anyone have any insight into this?
Thanks in advance!
Scott
Scott Rigby
http://basekamp.com
http://PlausibleArtworlds.org
http://UtopiaSchool.org
rename function
I believe you are forgetting to rename the "function mymodule_form_alter(..." part. In your example, you would put "function nopreview_form_alter" instead. and this file would be named nopreview.module. The info file would then be named nopreview.info (putting both of those files in a folder called /sites/all/modules/nopreview).
about hiding the preview button
I have content type which is developed using cck.I donot want the preview button on that.Is your approach help me.
check form names once again
un comment the echo("form_id".$form_id); and check once again whether form ids are written correct. one more thing you need to check is function name. if your module name is "noextrainfo", your function name should be noextrainfo_form_alter($form_id,&$form).
that's it.
Can I do it without a module?
Hi,
Is it possible to hide the Preview button without a module? I just want to hide it for 1 content type. Thanks,
David
Using CSS
Try this using CSS
I entered the following into my themes style sheet. Worked a charm. But it does remove all preview buttons on the site.
#edit-preview {
display:none;
}
create a
create a comment-form.tlp.php in your theme directory (if you don't already have one). And add this:
--
Tom
kirkdesigns.co.uk - web design and development
--
Tom
www.systemseed.com - drupal development. drupal training. drupal support.
Yes you can
I got this from another thread and I modified it slightly to work within my own module
This line: unset($form['buttons']['preview']);
That removes the preview button just for this "metadatagath_node_form" form.
It works!
Perfectly! Just changing the appropriated variables, it works perfectly. Thanks!
solution to remove preview button for page
Hi tille,
It's simply use the form alter hook to resolved this problem : have a look below example.
use below code for custom module:-
function modulename_form_alter($form_id ,&$form){
if($form_id == "content_type_name_node_form"){
unset($form['buttons']['preview']);
}
}
and you found form_id to print below example :-
function modulename_form_alter($form_id ,&$form){
print_r($form_id);
}
module to hide preview button from settings
No workie
....at least not with my D6.4 build.
warning: Missing argument 1 for nopreview_menu() in /home/my_website/public_html/sites/all/modules/nopreview/nopreview.module on line 10.
Line numbers added for clarity:
Anybody have any ideas...??
I've tried every trick mentioned here so far to not show a simple "preview" button (or better, disable it), with nil results....
Cheers,
//TB
[FIXED]! This kills Preview w/ D6.4
Came across this sandbox, where "preview_plug" module does EXACTLY what I needed: killing off the Preview button on a node-type by node-type basis (or across the entire site, by default):
http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/deekayen/mo...
Cheers!
//TB
Hiding PREVIEW button for one specific page with css
Hiding PREVIEW button for one specific page with css: http://drupal.org/node/194890#comment-1161353
---
How to contribute to Drupal.
Drupal 6
nopreview.module
nopreview.info
That is brilliant
Thanks.
Any chance we could expand it to cover comments and their preview buttons...?
That's fantastic, but as
That's fantastic, but as another pointed out, does not account for comment forms.
In Drupal 6.10 I have tried both these and neither works:
Anyone have any idea why neither of these works? Hmmmmmm.
D'oh!
The first one of mine should work. I'm working with another developer who has been focused on theming. He had another custom module that re-created the comment form's Preview button after I unset it (because his module is 'heavier' than mine, it executes its hooks after mine). No wonder!
Unsetting wrong var
Use:
unset($form['buttons']['preview']);Drupal 5
If you ever decide to contribute this as a module, let me know. I have ported it to drupal 5 if someone wants it.
Contributed module?
could the proposed solution(s) find its way into contributed modules?
There is now a module for that
Just for the record:
http://drupal.org/project/preview
then go to "Post Settings" and there you can globally disable the preview button.
Just give it an access = 0
guys, just give it an access = 0 to almost anything you want to hide in the form..
this is something that I've been using for a long time now and it's better than unset because sometime doing unset breaks down the form.. once I've tried to hide the path and menu items (collapsible) by unsettling them and the nodes would not appear in proper places.. but hiding is not an extreme solution as unsettling, because everything is still there, you just choose to hide it in the form that the user is previewing.
example - Hiding the preview button.
ModuleName_form_alter(&$form, &$form_state, $form_id) {
$form['preview']['#access'] = 0;
}
Remeber that that first you have to put preview settings optional.. it's not wise to hide something that is required.. you can put preview optionally by going to the content type settings (under edit)
hope this helps..
take care..
i've just realize that this
i've just realize that this is under drupal 5... this solution is for drupal 6 (also i don't know if it will work in drupal 7, although I'm guessing it will)..
#access method is ok
butyou made a typo (drupal 6) :
$form['buttons']['preview']['#access'] = 0;
does not work in drupal 7
Folks,
In Drupal 7, unset ($form['preview']); does not un-set the preview button.
The following does not work either:
unset ($form['preview']);
unset($form['buttons']['preview']);
$form['preview']['#access'] = 0;
$form['preview'] = null;
And yes, I did enable my module, and the naming conventions are correct. I cleared the cache every time I made a change to the module.
Does anyone know why this little tiny thing is so difficult in version 7? And more importantly, how to get it to work?
Thanks
p.s. I installed and enabled the "preview" module, and it doesn't work either! (http://drupal.org/project/preview)
Preview before submitting
I think it is built into D7... Did you try this?
For nodes:
Under the title field "Preview before submitting" select Disabled.
For comment settings:
Under "Preview comment" select Disabled.
Yes, that worked! Cheers!
Yes, that worked! Cheers!
Correct Syntax for D7
In response to Jag339, the correct way to do this for Drupal 7, through hook_form_alter, in a custom module, is:
unset($form['actions']['preview']);
using ['buttons'] does not work.
Matt
Actually,
Actually, using:
Is better than using:
Contact me to contract me for D7 -> D10/11 migrations.