Adding force preview to node and changing value of submit button in Drupal?

This question is twofold:

  • Is there a way to force the user to preview a SPECIFIC node before submitting? i.e. not all nodes using / admin / content / node-settings ... but only ONE specific node.
  • Is there a way to change the shortcuts instead of saying "submit" and "preview" rather say "Process" and "Review"?
+2


source to share


2 answers


The main answer to both questions is hook_form_alter()

. You will need to check the parameter $form_id

to determine if you are in an edit node form (they get an id [contenttype]_node_form

, see the first line of the implementation example on the API docs page for a launching method for all content types).

For your need 1, you would check $node->nid

to determine if this is your specific node. If so, you would change the "#access" submission form definition elements to disable it if you are not on the preview page (see node_form()

the node module for how Drupal does this - pretty far from the end of the function).



For your need 2, you just change the "#value" entries in the submit and preview button definition in the $ form array.

+3


source


You can change if a preview is required before publishing to /admin/content/node-settings

(Drupal 6).



As far as changing the button text, you will probably have to do it either through code in the form or somewhere in your theme.

+1


source







All Articles