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

4 comments:

  1. Nice tutorial, btw is there any upgrade safe way to achieve this?

    ReplyDelete
  2. A simple way to make it upgrade friendly is to redefine the getSettings method by adding your own script. See : http://alanstorm.com/magento_html5_tinymce

    ReplyDelete
  3. Marvelous and fascinating article. Incredible things you've generally imparted to us. Much obliged. Simply keep making this kind out of the post.
    custom magento development

    ReplyDelete
  4. Non commercial use good deal found proper outside Spokane, Washington Shipping Container Homes. Great spot for both higher-end household residing as well as boutique shopping; Great deal is undervalued and the addition of any allowed home unit’s increases house importance significantly.

    ReplyDelete