description

Here's a simple way to disable TinyMCE on textareas where the id is named dynamically. I needed this for use with the flashvideo_module. It creates a textarea that lists the uploaded video, and names it id = 'edit-files-XYZ-description', where XYZ is the file id (fid) and is unique to each node.

Step 1 of 1

Grab the theme_tinymce_theme function from tinymce.module, and copy it to your template.php file, renaming it to phptemplate_tinymce_theme, then modify it as follows:

function phptemplate_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
  if ($textarea_name = 'files-'.$node->fid.'-description'){
  $flashvid_exempt = $textarea_name;
  }
  switch ($textarea_name) {
    // Disable tinymce for these textareas
    case 'log': // book and page log
    case 'img_assist_pages':
    case 'caption': // signature
    case 'pages':
    case 'access_pages': //TinyMCE profile settings.
    case 'user_mail_welcome_body': // user config settings
    case 'user_mail_approval_body': // user config settings
    case 'user_mail_pass_body': // user config settings
    case 'synonyms': // taxonomy terms
    case 'description': // taxonomy terms
	case $flashvid_exempt:
      unset($init);
      break;

The rest of the code in this function is unchanged, so I didn't duplicate it here.

Hopefully this approach is useful to someone else.

Doug Gough

Comments

kingandy’s picture

I'd lose the first comparison and do something like the following:

function phptemplate_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
  $flashvid_exempt = 'files-'.$node->fid.'-description';
  switch ($textarea_name) {
    // Disable tinymce for these textareas
    case 'log': // book and page log
    case 'img_assist_pages':
    case 'caption': // signature
    case 'pages':
    case 'access_pages': //TinyMCE profile settings.
    case 'user_mail_welcome_body': // user config settings
    case 'user_mail_approval_body': // user config settings
    case 'user_mail_pass_body': // user config settings
    case 'synonyms': // taxonomy terms
    case 'description': // taxonomy terms
    case $flashvid_exempt:
      unset($init);
      break;

... Actually, come to think of it, is $node even available in template.php?

--Andy
Developing Drupal websites for Livelink New Media

++Andy
Developing Drupal websites for Livelink New Media since 2008