Drupal 6 tinymce: Disable tinymce on textarea (how to overide theme_tinymce_theme() function)
It's impossible to override this function.
Why? Look at the functions name. It confusses drupal thinking its an implementation of hook_theme(). So any override in template.php using phptemplate_tiny_mce() or theme_name_tinymce_theme() wont work.
You need to patch the module.
If you want to add a text area that doesnt need tinymce just add an other rule shown by the id of 'my-textarea'.
<?php
/**
* Customize a TinyMCE theme.
*
* @param init
* An array of settings TinyMCE should invoke a theme. You may override any
* of the TinyMCE settings. Details here:
*
* <a href="http://tinymce.moxiecode.com/wrapper.php?url=tinymce/docs/using.htm
">http://tinymce.moxiecode.com/wrapper.php?url=tinymce/docs/using.htm
</a> *
* @param textarea_name
* The name of the textarea TinyMCE wants to enable.
*
* @param theme_name
* The default tinymce theme name to be enabled for this textarea. The
* sitewide default is 'simple', but the user may also override this.
*
* @param is_running
* A boolean flag that identifies id TinyMCE is currently running for this
* request life cycle. It can be ignored.
*/
function theme_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
// uncomment to debug this
/* print_r($init);
print_r($textarea_name);
print_r($theme_name);
print_r($is_running);
*/
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
//add your rule here
case 'my-textarea':
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;
}
/* Example, 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['extended_valid_elements'] = array('a[href|target|name|title|onclick]');
break;
}
}
*/
// Always return $init
return $init;
}
?>
Add new comment