You are here

function wysiwyg_template_form_node_form_alter in Wysiwyg API template plugin 7.2

Same name and namespace in other branches
  1. 8.2 wysiwyg_template.module \wysiwyg_template_form_node_form_alter()
  2. 3.0.x wysiwyg_template.module \wysiwyg_template_form_node_form_alter()

Implements hook_form_FORM_ID_alter().

File

./wysiwyg_template.module, line 538
Makes TinyMCE Templates available as plugin for client-side editors integrated via Wysiwyg API.

Code

function wysiwyg_template_form_node_form_alter(&$form, &$form_state, $form_id) {
  _wysiwyg_template_set_node_type($form['type']['#value']);
  if (!empty($form['nid']['#value'])) {

    // This is an existing node and we do *not* apply a template.
    return;
  }
  $type = $form['type']['#value'];
  $name = wysiwyg_template_load_default($type);
  if (empty($name)) {

    // There is no default defined and we have nothing to do.
    return;
  }
  $body = wysiwyg_template_html_load($name);
  if (empty($body)) {

    // Nothing to do.
    return;
  }
  $form['body'][LANGUAGE_NONE][0]['#default_value'] = $body;
}