Tuesday 6 December 2011

Remove tinymce from drupal block edit page when format is set to PHP


Small one this to compliment our other article on removing tinymce from select textareas, this enhancement will hide tinymce from the Drupal block edit screen when the input format is set to PHP. This stops the problem of tinymce stripping the PHP tags from the block edit textarea when you edit your block

The following function goes into your template.php file and will solve the problem of tinymce showing up on a block when the format is set to PHP

function phptemplate_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
print $textarea_name;
switch($textarea_name){
//add text areas to disable tinymce for
case ‘log’:
unset($init);
return $init;
break;
case ‘body’:
if (arg(0)==’admin’ && arg(1)==’build’ && arg(2)==’block’){
$format = db_result(db_query(”
SELECT format
FROM {boxes}
WHERE bid=%d”,$bid
));
if ($format==2){
unset($init);
return $init;
}
}
default:
return theme_tinymce_theme($init, $textarea_name, $theme_name, $is_running);
}
}