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.

  1. Make sure you are using the TinyMCE editor.

  2. Open the htmlarea.php file in the /includes/ folder of the /storeadmin/ folder.

  3. Add the code

    if ($setpg == "weblinks")
    {
    $java = "description";
    $show_htm_edit = "yes";
    }

    just above the line

    // NO IPHONES IPADS OR IPODS
  4. 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",
  5. 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 : "", 
  6. Save and reload the file.

  7. 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.