Hi!

Can I automatically disable tinymce in a particular textarea?

Thanks,

Aina

Comments

geologyrocks’s picture

I use Moxie - an offshoot of TinyMCE, but it should be possible in TinyMCE also to exclude textareas on certain pages, e.g. in the Admin pages.

Look in the admin for TinyMCE and you should see a "Visibility" section. To prevent TinyMCE appearing on admin page put admin/* on the textbox and click the "Show on every page except the listed pages." radio button.

You could also turn on the "Show disable/enable rich text editor toggle:" such that you can turn of TinyMCE when it gets in the way.

Hope that helps.

Jon

-----------------------------------------------
GeologyRocks: http://www.geologyrocks.co.uk

mrsocks’s picture

I am looking for the same thing "to disable the tinymce editor on certain textboxes".

On my 'edit content' page, there is the body copy area textbox that i want to have the editor, but then there is also a comment box that I dont want to have the editor. Is this possible?

mgifford’s picture

I was looking to implement this too.

Closest I could find was:
http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/mode

For the moment I'm just setting TinyMCE as disabled by default and assuming that people will enable it when it is required.

Mike
--
OpenConcept | SEO | Tech | Screencasts

jiangxijay’s picture

This doesn't work for other content types because, as soon as you go into node editing, the URL changes to node/ etc. The path goes away.

BradM’s picture

Just follow the visibility example, put 1 line after line where you don't want it to appear (make sure you hit the radio button for this option.)

Different examples,

node/add/*
node/add/story/*
node/*/story/*
forum/*

First line will not show tinymce on any add new node pages; second will not show tinymce on any added story nodes only, third example will not show tinymce on any pages with story nodes (edit/add/delete) and fourth example won't show tinymce on any form in your forums.

jiangxijay’s picture

Oh, yeah! I'm still wondrously discovering meaningful URLs for *everything*. Thanks!

mgifford’s picture

That works quite fine if you want to disable all of the textareas on a page. However what I wanted (and what I thought the original post was on), was disabling a specific text area on a page. So perhaps they'd have a form with a few textarea boxes, but one of them needs to just use plain text and not have the wysiwyg applied.
--
OpenConcept | SEO | Tech | Screencasts

jiangxijay’s picture

Agreed.

meerkat’s picture

The solution posted at the following does the job:

http://avocadoshake.net/blog/2007/08/20/how-disable-tinymce-fields-drupa...

bigbman’s picture

It would seem that the TinyMCE module could have a setting to enable or disable for specific node type forms (i.e. enable only for Books or disable for Comments). Too bad it doesn't have this...

exotec’s picture

there is a nice module, which worked perfectly for me: Wysiwyg API

Alan D.’s picture

Here is a defacto that we use a lot.

<?php
/**
 * This allows you to override which text-areas get tinymce
 *
 * @param unknown_type $init
 * @param unknown_type $textarea_name
 * @param unknown_type $theme_name
 * @param unknown_type $is_running
 * @return unknown
 */
function phptemplate_tinymce_theme ($init, $textarea_name, $theme_name, $is_running) {
  $init = theme_tinymce_theme($init, $textarea_name, $theme_name, $is_running);
  $unwanted_content_types = array('simplenews');
  switch ($textarea_name) {
    // Disable tinymce for these textareas
    case 'code': // execute php
    case 'nodewords-description': // nodewords
    case 'extra-items': // webform existing items
    case 'webform-additional-validate': // webform component (older version)
    case 'webform-additional-submit': // webform component (older version)
    case 'extra-items': // webform existing items  (newer version)
    case 'additional-validate': // webform component 
    case 'additional-submit': // webform component 
    case 'field-extra-options': // webform component
    case 'field-extra-questions': // webform component
    case 'field-value': // webform component (default value)
      
      unset($init);
      break;
  }  
  if (isset($init)) {
    $init['theme_advanced_resize_horizontal'] = 'true';
    $init['convert_urls'] = 'false';
    // $init['extended_valid_elements'] = array('code');

    // Remove the editor from certain content types: remove the following line to get the correct string edit-XX
    //dpr($textarea_name);
    if($textarea_name == 'body') {
      if (preg_match('/^node\/([0-9]*)\/edit/', $_GET['q'], $matches)) {
        if ($node = node_load(array('nid'=>$matches[1]))) {
          if(in_array($node->type, $unwanted_content_types)) {
            unset($init);
          }
        }
      }
      elseif (preg_match('/^node\/add\/(.*)/', $_GET['q'], $matches)) {
        if(in_array($matches[1], $unwanted_content_types)) {
          unset($init);
        }
      }
    }    
  }
  return $init;
}

?>

Alan Davison
www.caignwebs.com.au

Alan Davison
ts230’s picture

Just replace this function in ther file tinymce-3.js with this:


/**
 * Attach this editor to a target element.
 *
 * See Drupal.wysiwyg.editor.attach.none() for a full desciption of this hook.
 */
Drupal.wysiwyg.editor.attach.tinymce = function(context, params, settings) {
  // Configure editor settings for this input format.
  
  //Don't add TinyMCE on comment fields.
  if(params.field == "edit-comment"){
  	document.getElementById('edit-comment').value = "";
  	return;
  }
  var ed = new tinymce.Editor(params.field, settings);
  // Reset active instance id on any event.
  ed.onEvent.add(function(ed, e) {
    Drupal.wysiwyg.activeId = ed.id;
  });
  // Make toolbar buttons wrappable (required for IE).
  ed.onPostRender.add(function (ed) {
    var $toolbar = $('<div class="wysiwygToolbar"></div>');
    $('#' + ed.editorContainer + ' table.mceToolbar > tbody > tr > td').each(function () {
      $('<div></div>').addClass(this.className).append($(this).children()).appendTo($toolbar);
    });
    $('#' + ed.editorContainer + ' table.mceLayout td.mceToolbar').append($toolbar);
    $('#' + ed.editorContainer + ' table.mceToolbar').remove();
  });
  // Attach editor.
  ed.render();
};

That gives you plain comments, but feel free to add as many more ID's of text areas as you want! Hope this helps someone!

bobbungee’s picture

mgifford - November 7, 2007 - 07:49

That works quite fine if you want to disable all of the textareas on a page. However what I wanted (and what I thought the original post was on), was disabling a specific text area on a page. So perhaps they'd have a form with a few textarea boxes, but one of them needs to just use plain text and not have the wysiwyg applied.

You could always define a new Input Format (Administer -> Site Configuration -> Input Formats). Then you could just set the textarea to use the custom input format.

mgifford’s picture

There have been a bunch of good ideas since then. The WYSIWYG module is great for controlling this.