开发者

Joomla TinyMCE editor do not save inserted image

We are building joomla component. And we use joomla editor in which we insert content.

But there开发者_运维百科 is a problem, because when we add image to editor and save it, it do not add image to database and when we opening this element to edit it again, there is only text in editor, image disappears.

This is how we use it:

$editor =& JFactory::getEditor();
echo $editor->display('text', $this->hello->text, '800', '300', '20', '20');

Maybe there is need to supply aditional parameters to display method?


Problem solved.

The standard way of getting the form data $post = JRequest::get('post'); is not enough in the case of using a editor. This will filter the content, hence losing line breaks and paragraps. So we need to add an extra line to get the editor contents in a raw unfiltered way. This data will be passed to the model to save into the database.


To get HTML form post data you need to get this data in following way

$data = JRequest::getVar( 'editorName', 'defaultValue', 'post', 'string', JREQUEST_ALLOWRAW );

And need to add a javascript for the view(tmpl file)

function submitbutton(action) {
          var form = document.adminForm;
  switch(action)
  {
  case 'save':case 'apply':   
   <?php
                 $editor =& JFactory::getEditor();
                 echo $editor->save( 'editorName' );
         ?>
  case 'publish':
  case 'unpublish':
  case 'cancel':
  default:
   submitform( action );
  }
 } 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜