When Modules Collide

I just encountered a problem arising from a combination of the TinyMCE WYSIWYG module and the FAQ module in Drupal 6.

In a nutshell:

  • Unless otherwise configured, the TinyMCE module attaches a WYSIWYG editor to any HTML textarea it encounters on a node editing page.
  • The FAQ module takes the liberty of modifying the node editing form, using the title field to store the Question, and making it a textarea instead of a textfield.
  • Drupal escapes any HTML it finds in a node's title field.

The Question (title) field was getting wrapped in a WYSIWYG editor, which was wrapping some HTML around the field contents... when the FAQ node was saved and displayed, that HTML was getting escaped and showing up on screen.

Suspecting that I couldn't have been the first person to encounter this problem, I went searching on Drupal.org and found an issue in the FAQ module queue: http://drupal.org/node/254336

That issue contained a link to another page describing how to write a custom theme function for TinyMCE and tell it to leave specific fields alone: http://drupal.org/node/179462

So, by adding a theme function to my theme's template.php file, I was able to disable TinyMCE for all fields named 'title'... problem solved.

I'm continually impressed by how many Drupal issues like this can be resolved without hacking either the module or the Drupal core. The resolution sometimes seems a bit tedious, especially when you've looked at the module code and can see right where you could fix it with one extra line or conditional block, but when it comes time to upgrade it is well worth not having to remember what hacks you made and where.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

patches welcome!

The other thing you could do is submit a patch to the issue queue for that module. It depends of course on the context, but I'm sure many users less capapble than you would also like that fix

Good point

When you're wrapped up in your own work trying to juggle priorities or meet a deadline it's easy to just solve a problem and move on, but if you can share the fix with an extra fifteen minutes, it's a nice courtesy to the Drupal community.

I've had to do the same

I've had to do the same thing with the TinyMCE theme function, but there's no reason for the FAQ module to use a textarea for its questions in the first place.

Unless of course, like my

Unless of course, like my client, your questions are two sentences long. I think I solved this problem by telling the WYSIWYG editor to ignore that particular input's id a few months ago. It was a strange little bug. If you support textarea, I wish it could support formatting.

Instead of changing FAQ, we could submit a patch to core to help it understand HTML inside of node titles. Which, in certain circumstances, I WOULD like to emphasize a word or change the color of a phrase WITHIIN the title and just have the html be stripped where appropriate.

Josh

I ran into this as well.

I also ran into the same problem. I also didn't want to modified the contributed FAQ module to change the title to a textfield so I just created a faq-manager role/user and didn't grant TinyMCE permssions for that role.

We also ran into the same issue using the Webforms module and TinyMCE. The person that discovered the issue with Webforms found a PHP snippet that could be put in the Visibility configuration session of the TinyMCE settings page. Instead of including or excluding pages by name, using the "show if following PHP code returns true" option would allow to limit the use of TinyMCE to specific node types. However, was just playing around with the snippet and it doesn't seem to work as advertised.

Solution: Wysiwyg API

TinyMCE module is officially abandoned now.

Use Wysiwyg API with TinyMCE instead.

TinyTinyMCE

The TinyTinyMCE module, which is really just a wrapper for TinyMCE (the editor, not the TinyMCE Drupal module), allows you to specify which textareas to leave alone, so you can use a configuration option to leave the editor off title fields instead of patching a module.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><p><div> <br><img>
  • Lines and paragraphs break automatically.

More information about formatting options

Verification
This question is for testing whether you are a human visitor and to prevent automated spam submissions.