VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: anonunder on February 21, 2018, 16:45:41 PM

Title: TinyMCE Editor doesn't work on Custom Fields
Post by: anonunder on February 21, 2018, 16:45:41 PM
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>';



Title: Re: TinyMCE Editor doesn't work on Custom Fields
Post by: anonunder on February 21, 2018, 17:10:37 PM
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>';
Title: Re: TinyMCE Editor doesn't work on Custom Fields
Post by: Studio 42 on February 21, 2018, 23:14:23 PM
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.