Tuesday, April 30, 2013

Magento Allow Style/Script/HTML5 Tags in CMS Pages

Magento Enterprise version 1.14.0.1

Problem:

The Magento rich text editor tinymce removes style, script, and html5 tags when CMS pages, static block etc. are saved.

Solution:

Warning – requires a source code change and is NOT upgrade friendly.

  1. Edit file \js\mage\adminhtml\wysiwyg\tiny_mce\setup.js
  2. Find the section starting with: var settings = {
  3. Add a new parameter e.g. paste the following code (to allow style, script, html5 tags) after the line: theme_advanced_resizing : true,

extended_valid_elements : 'style,script,section,article,aside',

Note that the tinymce version number can be found in this file: \js\tiny_mce\tiny_mce_src.js

 

Magento Community version 1.7.0.2

Problem:

The Magento rich text editor tinymce removes style tags when CMS pages, static block etc. are saved.

Solution:

Warning – requires a source code change and is NOT upgrade friendly.

  1. Edit file \js\mage\adminhtml\wysiwyg\tiny_mce\setup.js
  2. Find the section starting with: var settings = {
  3. Add a new parameter e.g. paste the following code (to allow style tags) after the line: theme_advanced_resizing : true,

valid_children : '+body[style]',

And to allow both style and script tags:

valid_children : '+body[style|script]',

Note that the tinymce version number can be found in this file: \js\tiny_mce\tiny_mce_src.js