Toggling TinyMCE and formatting tips

In an effort to reduce clutter on the average user's node creation form, I wanted to hide the formatting tips when TinyMCE was active. There's little reason for them to see Web page addresses and e-mail addresses turn into links automatically. etc. when they have a nice wysiwyg running already. Turning the editor off, however, should bring the tips back.

This is a two-step process. The first is to add a small custom module which implements hook_form_alter. It will wrap the whole formatting section in a classed div.

<?php
function site_custom_module_form_alter($form_id, &$form) {
  if (isset(
$form['type']) && $form_id == $form['type']['#value'] .'_node_form') {
   
// give the formatting tips a div so tinymce can affect them
   
if (is_array($form['body_filter']['format'])) {
     
$form['body_filter']['format']['#prefix'] = '<div class="formatting-tips">';
     
$form['body_filter']['format']['#suffix'] = '</div>';
    }
  }
}
?>

The next part requires a few alterations to the tinymce_process_textarea function in tinymce.module. Change $tinymce_invoke to :
<?php
$tinymce_invoke
= <<<EOD

  tinyMCE.init({
   
$tinymce_settings
  });
  // hide the formatting tips when TinyMCE loads
  $(document).ready(function(){
    $(".formatting-tips").hide();
  });

EOD;
?>

Change $js_toggle to:
<?php
$js_toggle
= <<<EOD

  function mceToggle(id, linkid) {
    element = document.getElementById(id);
    link = document.getElementById(linkid);
    img_assist = document.getElementById('img_assist-link-'+ id);

    if (tinyMCE.get(element.id) == null) {
      tinyMCE.execCommand('mceAddControl',false, element.id);

      element.togg = 'on';
      link.innerHTML = '
$disable';
      link.href = "javascript:mceToggle('" +id+ "', '" +linkid+ "');";
      if (img_assist)
        img_assist.innerHTML = '';
      link.blur();

      //hide the formatting tips while TinyMCE is on
      $(".formatting-tips").hide();
    }
    else {
      tinyMCE.execCommand('mceRemoveControl',false,element.id);
      element.togg = 'off';
      link.innerHTML = '
$enable';
      link.href = "javascript:mceToggle('" +id+ "', '" +linkid+ "');";
      if (img_assist)
        img_assist.innerHTML = img_assist_default_link;
      link.blur();

      //show the formatting tips while TinyMCE is off
      $(".formatting-tips").show();

    }
  }

EOD;
?>

I grant a patch file would be better than all that pasted code.

This method will only work if the user editing/creating the node only has access to one input format.

nice post!!

If I am not wrong TinyMCE is meant to be a client side application it does not include native file managers for various server technologies.