VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Gruz on March 19, 2012, 19:31:51 PM

Title: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: Gruz on March 19, 2012, 19:31:51 PM
J2.5.3
VM SVN
JCE is the editor, NOT TinyMCE

I've added a test field.

(http://static.xscreenshot.com/2012/03/19/18/screen_8a67e3b23c4f215f278a58b60770f9ee) (http://view.xscreenshot.com/8a67e3b23c4f215f278a58b60770f9ee)

When I first time add the custom field it's ok:
(http://static.xscreenshot.com/2012/03/19/18/screen_463ad23e1ee613446f53216a0ba6b259) (http://view.xscreenshot.com/463ad23e1ee613446f53216a0ba6b259)

I press save and see a regular textarea instead of the editor area:

(http://static.xscreenshot.com/2012/03/19/19/screen_eda8c6864a87b96d22b4ad5fbd8bb533) (http://view.xscreenshot.com/eda8c6864a87b96d22b4ad5fbd8bb533)


The key place is in administrator/components/com_virtuemart/models/customfields.php

Line 398
case 'X':
return '<textarea class="mceInsertContentNew" name="field['.$row.'][custom_value]" id="field-'.$row.'-custom_value">'.$field->custom_value.'</textarea>
<script type="text/javascript">// Creates a new editor instance
tinymce.execCommand("mceAddControl",true,"field-'.$row.'-custom_value")
</script></td><td>'.$priceInput;
//return '<input type="text" value="'.$field->custom_value.'" name="field['.$row.'][custom_value]" /></td><td>'.$priceInput;
break;


The code works for New editor, but not for a previously saved.

I tried to use:
$editor =& JFactory::getEditor();
return $editor->display('field['.$row.'][custom_value]',$field->custom_value, '550', '400', '60', '20', false).'</td><td>';

But there is a joomla bug (I think). When the code I tried is called  from administrator/components/com_virtuemart/views/product/view.json.php it fails:
Fatal error: Call to undefined method JDocumentJSON::addCustomTag() in /mnt/work/www/klokkenbouwen.nla/www/virtuemart/libraries/joomla/html/editor.php on line 258

When called from JSON view Joomla uses JDocumentJSON, but method addCustomTag is fromJDocumentHTML.

So my suggestion is to add this code:

$document=& JFactory::getDocument();
if (get_class($document) == 'JDocumentHTML') {
$editor =& JFactory::getEditor();
return $editor->display('field['.$row.'][custom_value]',$field->custom_value, '550', '400', '60', '20', false).'</td><td>';

}




Patch:

Index: components/com_virtuemart/models/customfields.php
===================================================================
--- components/com_virtuemart/models/customfields.php (revision 5689)
+++ components/com_virtuemart/models/customfields.php (working copy)
@@ -396,6 +396,12 @@
break;
//'X'=>'COM_VIRTUEMART_CUSTOM_EDITOR',
case 'X':
+ $document=& JFactory::getDocument();
+ if (get_class($document) == 'JDocumentHTML') {
+ $editor =& JFactory::getEditor();
+ return $editor->display('field['.$row.'][custom_value]',$field->custom_value, '550', '400', '60', '20', false).'</td><td>';
+
+ }
return '<textarea class="mceInsertContentNew" name="field['.$row.'][custom_value]" id="field-'.$row.'-custom_value">'.$field->custom_value.'</textarea>
<script type="text/javascript">// Creates a new editor instance
tinymce.execCommand("mceAddControl",true,"field-'.$row.'-custom_value")
Index: components/com_virtuemart/views/product/tmpl/product_edit_custom.php
===================================================================
--- components/com_virtuemart/views/product/tmpl/product_edit_custom.php (revision 5689)
+++ components/com_virtuemart/views/product/tmpl/product_edit_custom.php (working copy)
@@ -239,4 +239,4 @@

//onsole.log(jQuery('#customfieldsTable').data('events'));

-</script>
\ No newline at end of file
+</script>


Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: Studio 42 on March 23, 2012, 00:10:02 AM
I think is a code change in j2.5 because it work perfectly for me :(

Problem is that we have depedent of Joomla / motools javascript.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: Gruz on March 23, 2012, 00:11:35 AM
Have you payed attention, that the editor is NOT the default one? It works perfect with the default one.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: lipes on March 23, 2012, 02:41:27 AM
Same here.
I also have the JCE instaled and that Value field its now empty without editor
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: amorino on August 17, 2012, 00:57:15 AM
Hello
I have the same probleme here with JCE
Any help please?
Best regards
Amorino
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: amorino on August 17, 2012, 01:02:18 AM
And there is more :
After saving the editor JCE in description doesn't work any more

If I delete the custom field it works again

Any help please?
Best regards
Amorino
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: amorino on August 17, 2012, 01:11:24 AM
The patch above resolved my problem
Thank you Gruz
Best regards
Amorino
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: magoro on August 22, 2012, 17:27:54 PM
Thank's Gruz ! It's working now for me too. @ J2.5.6 , VM 2.0.7f

Are there possibilities of this patch go to the production version?
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: psyray on November 14, 2012, 18:18:46 PM
Thanks for this patch gruz.

Did you submit it to the dev team ?
It must be implemented in the future release ;)
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: alanbagl;ey on January 03, 2013, 13:25:57 PM
Nice fix. Worked for me.

Thank you
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: selor on January 03, 2013, 19:11:26 PM
HI all

Another Strange problem with Virtuemart 2.016 and JCE editor in the same area ...
Really boring it seems to be not corrected and it worst now ..

When you edit a product with custom field type Editor and use JCE as default :
Jce appears but you have to scale it up and virtuemart JS interprete it as you want to change the order .. and empty the content of the editor ..

Pliz help about it ... appreciated .. have many work to make on products ...

Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: alatak on January 03, 2013, 23:10:28 PM
Hello
Yes we are looking at the problem.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: selor on January 03, 2013, 23:31:58 PM
ok .. would it be possible to post a fix in this thread if you find a way ? thanks :)

Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: selor on January 05, 2013, 00:37:49 AM
HI and scuse tu up this one but really need a fix for this ..
I have more than 20000 ref to edit and this problem is amazingly important ...
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: alatak on January 08, 2013, 13:08:56 PM
Hello

The fast solution I have is to go in the JCE configuration and change the size of the editor
- go in Edit Profile - [Default]
- Change Editor width, and Editor Height, and
- set Editor resizing to No

We are going to the the changes inside VM but for the next version.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: Milbo on January 08, 2013, 16:24:38 PM
Quote from: selor on January 05, 2013, 00:37:49 AM
... more than 20000 ref to edit and this problem is amazingly important ...

Hahaha, yes that is the right attitude. A small piece of the whole thing, for most people completly unimportant, but if you need it, then it can turn out as blocker.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: jjk on January 08, 2013, 21:52:57 PM
Quote from: selor on January 05, 2013, 00:37:49 AM
I have more than 20000 ref to edit and this problem is amazingly important ...

When I have to edit a lot of database entries, I often use "HeidiSQL", a free mysql client, to edit the products directly in the database table. Saves a lot of clicks compared to using any Joomla editor.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: Datatonic on March 26, 2013, 15:34:03 PM
I am having the same problem but with jckeditor.

Does anyone know how to call an instance of that instead of tinymce?

Thanks.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: jjk on March 26, 2013, 17:53:32 PM
Quote from: Datatonic on March 26, 2013, 15:34:03 PM
I am having the same problem but with jckeditor.

As far as I know, VM uses a classname to identify editors. TinyMCE and JCE editors do have this classname to identify themselves. The other editors don't.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: Datatonic on March 26, 2013, 23:29:23 PM
Ok so how do I call either .... just for this instance when JCK is default.

I really don't want to put the client in a position of having to switch out user or default editor to edit these fields with a WYSIWYG editor.

JCK Calls fine for product descriptions with no core edits.

Any pointers?

Thanks.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: jjk on March 27, 2013, 16:55:53 PM
Quote from: Datatonic on March 26, 2013, 23:29:23 PM
...so how do I call either .... just for this instance when JCK is default.

Sorry, I have no idea at the moment. Maybe somebody else has. Personally I'm using JCE because that one works.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: Nenidd on June 27, 2013, 17:14:24 PM
Hello,

I try to install your path, but i don't understand the second part.


Index: components/com_virtuemart/views/product/tmpl/product_edit_custom.php
===================================================================
--- components/com_virtuemart/views/product/tmpl/product_edit_custom.php (revision 5689)
+++ components/com_virtuemart/views/product/tmpl/product_edit_custom.php (working copy)
@@ -239,4 +239,4 @@

//onsole.log(jQuery('#customfieldsTable').data('events'));

-</script>
\ No newline at end of file
+</script>


What I did make?

I work with joomla 2.5, Virtuemart 2.0.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: jjk on June 27, 2013, 18:26:01 PM
Quote from: Nenidd on June 27, 2013, 17:14:24 PM
I work with joomla 2.5, Virtuemart 2.0.
VirtueMart 2.0 is already 1 ½ years old. Use one of the latest versions (2.0.20b stable or a 2.0.21x developer version)
There is no need to alter the code. TinyMCE and JCE editors do work with newer versions of VM.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: Nenidd on June 28, 2013, 09:17:19 AM
So, i could change and it was work again?

I'm work on 2.0.6 exactly. And this bug make me crazy.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: jjk on June 28, 2013, 13:50:38 PM
Which editor do you use? TinyMCE and JCE 2.2.1 or higher do work within VirtueMart. Other editiors might not have implemented support for VirtueMart.
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: Nenidd on June 28, 2013, 14:49:55 PM
I make the upload! And it's work perfectly!
Thanks for you answer!
Title: Re: Editor custom field doesn't show editor on editing the product if not TinyMCE
Post by: OpenGlobal on September 11, 2013, 09:26:10 AM
This should be fixed in the next release. I've implemented the proposed code change.

OpenGlobal E-commerce