Add HTML snippets to the TinyMCE editor (v. 2.9-2.92)
If your customers want to add HTML code snippets (like social media plugins, affiliate codes, etc.) to their page or product content, you can use the following to create a pop up button to allow them to do that.
-
Make sure you are using the TinyMCE editor.
-
Open the htmlarea.php file in the /includes/ folder of the /storeadmin/ folder.
-
Add the code
if ($setpg == "weblinks") { $java = "description"; $show_htm_edit = "yes"; }just above the line
// NO IPHONES IPADS OR IPODS
-
change the code
toolbar1 : " bold italic underline strikethrough | forecolor backcolor | alignleft aligncenter alignright alignjustify | fontselect | fontsizeselect | styleselect | cut copy paste removeformat | bullist numlist | outdent indent blockquote | link unlink image gallery anchor | table | hr | undo redo | code fullscreen",
to
toolbar1 : " bold italic underline strikethrough | forecolor backcolor | alignleft aligncenter alignright alignjustify | fontselect | fontsizeselect | styleselect | cut copy paste removeformat | bullist numlist | outdent indent blockquote | link unlink image gallery anchor | table | hr | undo redo | customhtml code fullscreen",
-
Add the code
setup: function(editor) { editor.addButton('customhtml', { icon: 'newdocument', tooltip: 'Add Custom HTML Code', onclick: function() { editor.windowManager.open({ title: 'Insert HTML Code', body: [{type: 'textbox', multiline: true, minWidth: 450, minHeight: 100, name: 'htmlcode', value: ''}], onsubmit: function(e) { editor.insertContent(e.data.htmlcode); } }); } }); },just under the code
toolbar3 : "",
-
Save and reload the file.
-
At this point, if the store administrator clicks the 'Add Custom HTML' button in the HTML editor (page icon with the top right corner curled down), a pop up box will appear. The administrator can enter any text or HTML code here, and that code will be inserted wherever the cursor is in the content.