News:

Looking for documentation? Take a look on our wiki

Main Menu

TinyMCE Editor doesn't work on Custom Fields

Started by anonunder, February 21, 2018, 16:45:41 PM

Previous topic - Next topic

anonunder

Hello,

I got in console error when I try to use the editor on a custom field.

Uncaught ReferenceError: tinymce is not defined


customfield.php:


return $priceInput . '</td><td><textarea class="mceInsertContentNew" name="field[' . $row . '][customfield_value]" id="field-' . $row . '-customfield_value">' . $field->customfield_value . '</textarea>
<script type="text/javascript">// Creates a new editor instance
tinymce.execCommand("mceAddControl",true,"field-' . $row . '-customfield_value")

</script>';




anonunder

Fixed by adding  administrator/components/com_virtuemart/views/product/view.html.php at the top:

<script src="https://cloud.tinymce.com/stable/tinymce.min.js"></script>

and changing customfields.php

return $priceInput . '</td><td><textarea class="mceInsertContentNew" name="field[' . $row . '][customfield_value]" id="field-' . $row . '-customfield_value">' . $field->customfield_value . '</textarea>
<script type="text/javascript">// Creates a new editor instance
tinymce.execCommand("mceAddControl",true,"field-' . $row . '-customfield_value");
tinyMCE.init({
selector: "textarea.mceInsertContentNew",
  height: 500,
  theme: "modern",
  plugins: "print preview fullpage searchreplace autolink directionality visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists textcolor wordcount imagetools contextmenu colorpicker textpattern",
  toolbar1: "formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify  | numlist bullist outdent indent  | removeformat",
  image_advtab: true,
  });
</script>';

Studio 42

This work but is poor, because break when tinymce is used as editor in Joomla.
If you use tinymce as main Joomla editor, you should not have this bug.
If you really want to fix it, then you should load tinymce editor using Joomla. I dont have lust to check, but it's possible to do.