Skip to main content

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

An article from ComputerMinds - Building with Drupal in the UK since 2005
20th Sep 2008

Mike Dixon

Senior Mind
Hey, you seem to look at this article a lot! Why not Bookmark this article so you can find it easily in the future?

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);

}
}

Hi, thanks for reading

ComputerMinds are the UK’s Drupal specialists with offices in Bristol and Coventry. We offer a range of Drupal services including Consultancy, Development, Training and Support. Whatever your Drupal problem, we can help.