Hi, I am going completely crazy.

I click on Edit HTML, add my custom tags, like for example add:
<a href="myimage.jpg" rel="lightbox[][my caption]">

and automatically my special tags get stripped:
<a href="myimage.jpg" >

and so the rel parameter is eliminated and I can't use Lightbox!

I am going completely nuts, I just can't edit the source code as it gets everything filtered by TinyMCE after clicking on Update on the Edit HTML code TinyMCE's window.
That is, this happens without me clicking on Submit or Preview Post (also FULL HTML input is enabled - this is about TinyMCE which 'tidy ups' my code on Edit HTML window) .

I went to TinyMCE configuration and disabled all HTML Clean up options, but still, TinyMCE does not permit me to add my custom HTML tags.
Please help me, I've been struggling with this for more than an hour and I am going completely crazy.

Thanks!
Rod

CommentFileSizeAuthor
#5 tinymce.module.patch775 bytesTecHusky
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rodrix’s picture

Category: support » bug
Priority: Normal » Critical

This is actually critical, TinyMCE makes useless all input format as it strips out all unknown tags.
It also strips out php tags, and any tags that are unknown.

Do anyone have a solution for this?

rodrix’s picture

I found the solution myself.
You need to edit the tinymce.module file.

You should add your wanted extra html tags under this function:

function theme_tinymce_theme($init, $textarea_name, $theme_name, $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
      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;
  }

//FIRST!!!!! UNCOMMENT THIS EXAMPLE
  // 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':
//SECOND!!!!! ADD YOUR EXTRA HTML SUPPORTED TAGS HERE:
       $init['extended_valid_elements'] = array('a[href|rel|target|name|title|onclick|onmouseover]');
       break;
    }
  }

  

  // Always return $init
  return $init;
}

You should see the TWO steps that I marked.

Also there is a full XHTML tags defined on this patch that could come in very handy and could be considered an alternative solution: http://drupal.org/node/51097#comment-381617

This will help many. I read more than 15 support issues and TinyMCE FAQ's before getting to the solution.

In return, can someone tell me how to deactivate TinyMCE for modules that have Text Input = PHP, AND ONLY enable for blog posts, node, and comments .
I have found similar issues but only state the code for disabling PHP. Could anyone give me a hand and tell me the appropiate code to add?

Thanks!
Rod

spiffyd’s picture

Version: master » 6.x-1.x-dev
Component: User interface » Code
Status: Active » Closed (works as designed)

Rod,

No, thank you! Interestingly, I guess everyone's too anxious to configure their Lightbox than to reply with a simple thank you :P

At least there's the light side - no one else will go nuts anymore.

D

spiffyd’s picture

Status: Closed (works as designed) » Closed (fixed)

Fixed. Fin.

TecHusky’s picture

FileSize
775 bytes

Thank you SOO much! This did what the bottle of aspirin couldn't do for my headache after trying to figure this out for hours.

Edit: Here's a patch for this if anyone is interested... all it does is add "rel|" into the correct spot.

halley’s picture

VERY, very, very, very thanks man... u r my guru :)

loopduplicate’s picture

Don't edit the module file directly, override it in your theme. Right? For reference, here's a page explaining how to use the theme layer in Drupal: http://drupal.org/node/165706

re:

You need to edit the tinymce.module file.