News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Editor custom field doesn't show editor on editing the product if not TinyMCE

Started by Gruz, March 19, 2012, 19:31:51 PM

Previous topic - Next topic

Gruz

J2.5.3
VM SVN
JCE is the editor, NOT TinyMCE

I've added a test field.



When I first time add the custom field it's ok:


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




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>


Your installable language for VM2: http://gruz.org.ua/virtuemart-language-files.html

Studio 42

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.

Gruz

Have you payed attention, that the editor is NOT the default one? It works perfect with the default one.
Your installable language for VM2: http://gruz.org.ua/virtuemart-language-files.html

lipes

Same here.
I also have the JCE instaled and that Value field its now empty without editor
VM V. online: J2.5.14 | VM 2.0.20a | SQL 5.1.70 | PHP 5.3.25

amorino

Hello
I have the same probleme here with JCE
Any help please?
Best regards
Amorino
Création sites web Tunisie
http://www.idealconception.com

amorino

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
Création sites web Tunisie
http://www.idealconception.com

amorino

The patch above resolved my problem
Thank you Gruz
Best regards
Amorino
Création sites web Tunisie
http://www.idealconception.com

magoro

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?

psyray

Thanks for this patch gruz.

Did you submit it to the dev team ?
It must be implemented in the future release ;)


selor

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

Production: Joomla 2.5.8 | VM 2.0.15d | PHP Version 5.3.19 Apache 2.0 Handler

Safe Mode : Disabled
Disabled Functions:set_time_limit,passthru,exec,system,popen,shell_exec,proc_open

alatak


selor

ok .. would it be possible to post a fix in this thread if you find a way ? thanks :)

Production: Joomla 2.5.8 | VM 2.0.15d | PHP Version 5.3.19 Apache 2.0 Handler

Safe Mode : Disabled
Disabled Functions:set_time_limit,passthru,exec,system,popen,shell_exec,proc_open

selor

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 ...
Production: Joomla 2.5.8 | VM 2.0.15d | PHP Version 5.3.19 Apache 2.0 Handler

Safe Mode : Disabled
Disabled Functions:set_time_limit,passthru,exec,system,popen,shell_exec,proc_open

alatak

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.