In TinyMCE settings I can set up pages, where I want TinyMCE to be shown. But I want to directly set textareas, which are to be replaced by TinyMCE, like in HTMLarea settings.

Is this possible?

TinyMCE 1.44 CVS, Drupal 4.6

Comments

dandaka’s picture

I want TinyMCE to be shown when I edit pages only. I set "show on specific pages" filter to "node/*". Must works, but not! TinyMCE appears on comment textarea (because it's located on this url). Also, it doesn't appear on nodes with path aliases.

I think it's a serious obstacle and it's should be replaced with HTMLarea-style settings.

moshe weitzman’s picture

the current mechanism where users may enable disable the editor when they need it is just perfect IMO. the htmlarea configuration was annoying.

dandaka’s picture

This mechanism isn't flexible - fact. In some cases I have to forbid users to use rich-formatting.

Example: I want to use rich-formatting on page creation and not use on comments. This mechanism doesn't give me such possibility.

mitomac’s picture

For your case you want just,

node/add/*

in your tinymce profile settings. And remove the line:

comment/*

Also, make sure you have a recent build of the tinymce module, builds before about a week ago were ignoring the profile settings.

moshe weitzman’s picture

you must select the preference in admin/settings/comment for composing on separate page

dandaka’s picture

Why should I tune one module to make another work as I want? I think it's not right way. Also I do want comment field to be located on node page. It stimulates users to post comments.

dandaka’s picture

It doesn't work when comment field is displayed below post.

> Also, make sure you have a recent build of the tinymce module

of course I do :)

matt westgate’s picture

You can tweak tinymce per textarea, though it takes some knowledge of Drupal. You just override the theme_tinymce_theme function in your sites theme. Checkout the module's README for more details.

dandaka’s picture

Thanks, it also helps me.

But I think these settings must be avialable through module settings, not through 'knowledge of Drupal'.

matt westgate’s picture

You can read about overriding theme functions here:

http://drupal.org/node/11811

Sooner or later I imagine you'll want to do this for other design components of your site anyway.

Mahatma’s picture

... I say that because in accordance with the tinymce instructions I read, you may have to name each textarea with a unique id and then refer to them in tinymce by their id name as individual textareas.

Going through and renaming each textarea by adding "id=whatever" may be difficult to do. If you use a system of category/section/number that might be workable. say admin_login_1 ... whatever will give you numbers to work with that will identfy each section/page/textarea.

Then (and I haven't looked yet) if any textareas are created by a loop you can replace the parameters in the id on the fly ...

Make any sense?

dandaka’s picture

I say that because in accordance with the tinymce instructions I read

Can you point me?

dandaka’s picture

you may have to name each textarea with a unique id

Each textarea already have unique id. But how do I refer to them in TinyMCE? What do you mean by this? Should I modify javascript of TinyMCE to be shown only on specific textareas with needed ids? If so it can be a temporary solution, but it doesn't solve the problem.

Mahatma’s picture

you wanted to control which textareas were replaced with instances of the editor. Now I'm not sure what you meant. In any case, you may find that the commands for setting up htmlarea and tinymce are very much alike, but tinymce does not set up very much for you in default and htmlarea assumes what you want and does so.

If I'm not mistaken, the tinymce folder has a subfolder called "docs" and in combination with the information available on the tinymce support page, it tells you all the ways to set it up, which are nearly identical to htmlarea, but unfortunately you actually have to look at the documentation.

Sorry I couldn't help you,

dandaka’s picture

I want to control which textareas must be replaced with TinyMCE.

Your solution is to tune init script of TinyMCE (according to 'docs' folder). I should replace

tinyMCE.init({mode : "textareas"});

with

tinyMCE.init({mode : "specific_textareas"});

and then add to all textareas I want to be replaced with TinyMCE attribute mce_editable="true".

Do you think it's a good solution? It requires knowledge of HTML and Drupal internal mechanism just to set, where user wants to use rich-formatting. I think its too much.

Thanks for your help anyway :)

neofactor’s picture

If only there was simply an input filter called Rich Text editor... and it enabled the WYSIWYG if it was selected. This page by Page granulatrity would be nice.

David McIntosh
neofactor.com

Mahatma’s picture

... but then I thought you might just want to try different url's. Didn't someone suggest changing from /node to /somethingelse?

I wish I could help more, I just finished setting up tinymce on another cms but havent in Drupal yet, though I will because I like tinymce the best.

BTW try looking at the tinymce website manual pages to get all init details for tinymce ... look at http://tinymce.moxiecode.com/example_full.php?example=true
and read the PAGE SOURCE and copy whatever you want for your setup :)

PS - in another applicaton there is an iff(user=admin &&& pagesection=[siteinfo] || pagesection=[menus] || pagesection=[index]) then load tinymce ...

so it only loads the editor when certain pages are shown and only for the admin instead of loading for all users ...

If you can find that place in Drupal header block where the js scripts are inserted and the variable that records which page is being loaded, or at least which section the page is in, then let me know where please. I will be looking for it shortly as soon as I figure out how to make flash banners (which is very frustrating for a new-b).

gustav’s picture

I think the only way to switch off TinyMCE on individual textareas on a page which also contains other textareas where you want the editor is to have your theme override the theme_tinymce_theme() function. The default function starts with

  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
      unset($init);
      break;

Your override function would want to add an extra line there for each textarea where you want to switch off the editor.

Anonymous’s picture

Here's how I got rid of TinyMCE with the flashvideo module. Since the file description textarea is uniquely named with the fid (file id), for example id="edit-files-242-description" where 242 is the fid, I did the following:

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;

    // Force the 'simple' theme for some of the smaller textareas.
    case 'signature':
    case 'site_mission':
    case 'site_footer':
    case 'site_offline_message':
    case 'page_help':
    case 'user_registration_help':
    case 'user_picture_guidelines':
      $init['theme'] = 'simple';
      foreach ($init as $k => $v) {
        if (strstr($k, 'theme_advanced_')) unset($init[$k]);
      }
      break;
  }

  // Add some extra features when using the advanced theme.  
  // If $init is available, we can extend it
  if (isset($init)) {
    switch ($theme_name) {
     case 'advanced':
   $init['width'] = '100%';
       break;
   
    }
  }

  // Always return $init
  return $init;
}

Doug Gough

kulfi’s picture

Trying to disable TinyMCE when using Panels 2 (breaking the popup mechanism). What should I have in my switch statement to handle this?

Panels 2 generates the following HTML:

<textarea class="form-textarea resizable" id="edit-configuration-empty" name="configuration[empty]" rows="5" cols="60">No contacts listed.</textarea>

I've tried:

    case 'edit-configuration-body' :
      unset($init);
      break;
    case 'configuration[body]' :
      unset($init);
      break;
    case 'edit-configuration-empty' :
      unset($init);
      break;
    case 'configuration[empty]' :
      unset($init);
      break;

But none of these are working.

toodlepip’s picture

Had the same problem myself. You can see what the phptemplate_tinymce_theme() function is using for the textarea's by printing them out, so add:

print $textarea_name . '<br />\n';

as the first line of the function and the first thing on the page will be a list of the text areas that are trying to use the TinyMCE module. From what I've seen you need to use the name of the text areas rather than the id, so the code you'll need to use is:

    case 'configuration-body' :
    case 'configuration-empty':
      unset($init);
      break;

Hope that helps.

Toodle Pip

Sam

sun’s picture

All wysiwyg editors suffer from this.

Anyone interested in a generic wysiwyg API for Drupal should participate here:
http://drupal.org/project/wysiwyg
http://groups.drupal.org/wysiwyg

Daniel F. Kudwien
unleashed mind

Daniel 'sun' Kudwien
makers99

thomasmurphy’s picture

subscribing

webcomm’s picture

subscribing

kulfi’s picture