Default TinyMCE editor (wysiwyg - what you see is what you get) uses only several available in this editor tools. Today i want to show you how to increase number of available tools and how to change the source code to support all HTML tags + javascript. It's important, because by default this editor doesn't allow to use javascript + several html tags. In this tutorial i described step by step how to achieve that with modification of the PrestaShop files. If you don't want to edit files you can take a look on module: tinyMCE pro - extended rich text editor in PrestaShop - it does everything automatically and includes some additional features.
Simple Prestashop tinymce editor
TinyMCE extended version
open the file: _ADMIN_DIR_/themes/default/template/helpers/form/form.tpl near the line ~400 you've got something like:
$(document).ready(function(){ {block name="autoload_tinyMCE"} tinySetup({ editor_selector :"autoload_rte" }); {/block} });
This is a code where we have got tinyMCE editor object definition. We have to change tinySetup({ }) function. Change whole code to:
$(document).ready(function(){ {block name="autoload_tinyMCE"} tinySetup({ editor_selector :"autoload_rte", theme_advanced_buttons1 : "save,newdocument,bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect, fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,search,replace,bullist,numlist,outdent,indent,blockquote,undo,redo,link,unlink,anchor,image,cleanup,help,codemagic,insertdate,inserttime,preview,forecolor,backcolor", theme_advanced_buttons3 : "code,tablecontrols,hr,removeformat,visualaid,sub,sup,charmap,emotions,iespell,media,advhr,print,ltr,rtl,fullscreen", theme_advanced_buttons4 : "styleprops,cite,abbr,acronym,del,ins,attribs,visualchars,nonbreaking,template,pagebreak,restoredraft,visualblocks", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : false, extended_valid_elements: 'pre[*],script[*],style[*]', valid_children: "+body[style|script],pre[script|div|p|br|span|img|style|h1|h2|h3|h4|h5],*[*]", valid_elements : '*[*]', force_p_newlines : false, cleanup: false, forced_root_block : false, force_br_newlines : true }); {/block} });
This code will allow you to use extended version of the tinyMCE editor + editor will accept javascripts and additional html tags. That's all! Save changes and enjoy the changes! :)
Attention!
Prestashop in version 1.5+ has got new validation function, in this case it is also necessary to change Validate.php class, you can read about it here: validation class change - Lookig for tutorial about extending tinymce featured on product edit page? check this tutorial: full featured editor on product edit page
Module that does everything + new fancy features
Module that does everything automatically + includes some additional features not available in this article.
If you're interested in solution that will add font awesome icons, youtube videos insert tool or some other additonal things,
check official page of this module, it's available here: tinyMCE pro - extended rich text editor in PrestaShop