J1.5 talk

Difference between revisions of "Using the editor in a component"

From Joomla! Documentation

 
(4 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
== The tutorial is not complete ==
 
== The tutorial is not complete ==
  
Well what is happening is the following. The person who wrote the tutorial format one thing.  
+
Well what is happening is the following. The person who wrote the tutorial forgot one thing.  
  
 
In order to use the proposed javascripts the library file /includes/js/joomla.javascript.js had to be included. This is standard in de Joomla backend but not in many frontend templates.  
 
In order to use the proposed javascripts the library file /includes/js/joomla.javascript.js had to be included. This is standard in de Joomla backend but not in many frontend templates.  
Line 10: Line 10:
 
$document =& JFactory::getDocument();
 
$document =& JFactory::getDocument();
 
$document->addScript('includes/js/joomla.javascript.js');
 
$document->addScript('includes/js/joomla.javascript.js');
 +
 +
I have modified the tutorial but I at this point I don't know how to replace the included download files.
 +
 +
 +
== Possible Problems/Pitfalls ==
 +
When following this HowTo, I encountered these problems:
 +
* The string "description" for one reason or the other doesn't seem to work as editor name. In the javascript created by the editor component for saving the editor content, using "description" leads to a javascript error (tinymce.get('description') is undefined). Another, (shorter?) name (desc) worked fine. I didn't check whether it was the length, or if the string itself has some significance...
 +
* The user I tried it with first had CodeMirror configured as its default editor; with that it didn't work, I wrote about what the result looks like here (http://forum.joomla.org/viewtopic.php?f=620&t=644689&p=2604202#p2604202)
 +
* My component is running under Joomla 1.7, here the script (includes/js/joomla.javascript.js) include doesn't seem to be necessary anymore
 +
* The input filtering stuff doesn't work the way I expected; when doing the following, the database afterwards still holds an encoded string (e.g. > for >), instead of the "raw" html string, meaning I have to convert it back when displaying it (funnily enough I can just pass that string to the editor and it will show it formatted again, so it seems to do the back-converting by itself)
 +
$post['content'] = JRequest::getVar('content', '', 'post', 'string', JREQUEST_ALLOWRAW);
 +
[[User:Munchkin|Munchkin]] 07:25, 2 September 2011 (CDT)

Latest revision as of 13:58, 23 May 2013

I used a test site and implemented the editor in the frontend. The edit and display functions worked fine however the Save and Cancel do not execute anything. The Save and Cancel buttons that have been added to the form call a javascript function submitbutton. The submitbutton is executed however the documentation states that the editor's save method will trigger the save function in the controller which in turn calls the model's store method. This is not actually true. I am new to Joomla development so I thought maybe I typed it in wrong so I downloaded the completed example and it does not work either. The editor's save method does not trigger the controller which I believe is necessary. SO I think in order to make it work you need to trigger the controller directly from the button and bypass the javascript -submitbutton. I haven't tried it yet so if there any other suggestions. That would be great.

The tutorial is not complete[edit]

Well what is happening is the following. The person who wrote the tutorial forgot one thing.

In order to use the proposed javascripts the library file /includes/js/joomla.javascript.js had to be included. This is standard in de Joomla backend but not in many frontend templates.

You have to manually add the following. This can for example be done view.html.php $document =& JFactory::getDocument(); $document->addScript('includes/js/joomla.javascript.js');

I have modified the tutorial but I at this point I don't know how to replace the included download files.


Possible Problems/Pitfalls[edit]

When following this HowTo, I encountered these problems:

  • The string "description" for one reason or the other doesn't seem to work as editor name. In the javascript created by the editor component for saving the editor content, using "description" leads to a javascript error (tinymce.get('description') is undefined). Another, (shorter?) name (desc) worked fine. I didn't check whether it was the length, or if the string itself has some significance...
  • The user I tried it with first had CodeMirror configured as its default editor; with that it didn't work, I wrote about what the result looks like here (http://forum.joomla.org/viewtopic.php?f=620&t=644689&p=2604202#p2604202)
  • My component is running under Joomla 1.7, here the script (includes/js/joomla.javascript.js) include doesn't seem to be necessary anymore
  • The input filtering stuff doesn't work the way I expected; when doing the following, the database afterwards still holds an encoded string (e.g. > for >), instead of the "raw" html string, meaning I have to convert it back when displaying it (funnily enough I can just pass that string to the editor and it will show it formatted again, so it seems to do the back-converting by itself)
$post['content'] = JRequest::getVar('content', , 'post', 'string', JREQUEST_ALLOWRAW);

Munchkin 07:25, 2 September 2011 (CDT)