Keep line breaks, custom HTML attributes and remove initial paragraph tag in Magento Admin’s TinyMCE editor

In: Feeling guru|Techie Daw

4 Nov 2016

One of my clients would like to add additional HTML attributes for SEO purposes as well as to keep line breaks after saving a CMS block or page in the Magento Admin.

Solution:

To do that, you must open the file js/mage/adminhtml/wysiwyg/tiny_mce/setup.js and locate the line below:

var settings = {

Right after the code plugins : plugins, add the lines highlighted in grey:

        var settings = {
            mode : (mode != undefined ? mode : 'none'),
            elements : this.id,
            theme : 'advanced',
            plugins : plugins,
            forced_root_block: false,
            extended_valid_elements: '+ul[*],+li[*],+p[*],+span[*],+div[*],+a[*]',
            remove_linebreaks : false,
            theme_advanced_buttons1 : magentoPlugins ...

Save the file and clear your cache to apply the changes.

About the author

Richard Feraro is a Magento Enterprise Certified developer from Manila, Philippines with 14 years of solid open-source development experience using Linux, Apache, MySQL & PHP.

Comment Form

About my blog

This blog is targeted towards all levels of developers and also designers. Various topics are discussed such as Magento, PHP & MySQL, jQuery, WordPress, CSS and HTML.

Booking.com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 5,243 other subscribers

WordPress + Magento

Recent Trackbacks

Archives

Disclaimer

All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or my mom.