Actions

JFactory/getEditor

From Joomla! Documentation

Revision as of 05:38, 30 November 2012 by MattGarrod (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Returns a reference to the global editor object, only creating it if it doesn't already exist. The object returned will be of type JEditor.

Syntax

object JEditor getEditor( $editor )

where:

Argument Data type Description Default
$editor string The name of the editor (for example, 'tinymce'). If null then the current editor will be returned. null

Example

In this example, you can see how to display the editor and send specific display parameters.

$editor =& JFactory::getEditor();
$params = array( 'smilies'=> '0' ,
                 'style'  => '1' ,  
                 'layer'  => '0' , 
                 'table'  => '0' ,
                 'clear_entities'=>'0'
                 );
echo $editor->display( 'desc', '', '400', '400', '20', '20', false, $params );

In Joomla! 2.5 the parameters list for the display() function has been lengthened, so to use specific display parameters in 2.5:

$editor =& JFactory::getEditor();
$params = array( 'smilies'=> '0' ,
                 'style'  => '1' ,  
                 'layer'  => '0' , 
                 'table'  => '0' ,
                 'clear_entities'=>'0'
                 );
echo $editor->display( 'desc', '', '400', '400', '20', '20', false, null, null, null, $params );

$editor->display() must also be the first function called on the editor if you wish to use specific parameters.

For a complete list of parameters that can be passed to the TinyMCE editor, see the Joomla source file: /plugins/editor/tinymce.php.


HINT for your JModel:

Be aware that JRequest::GET by default filters all HTML-code down to plain text, which might not be very useful when using the editor.

To store HTML-code within your model class you MUST explicitely request HTML-Code from the JRequest-Object, otherwise all HTML will be stripped (and you might spend one day in debugging and reading docs like i did today).

/*The store-procedure in your model might then look like this*/
[...] 
function store()
{
  $row =& $this->getTable();
  $data = JRequest::get( 'post');
  /* Get proper HTML-code for your HTML-encoded field now by using JREQUEST_ALLOWHTML*/
  $data['yourfieldname']=JRequest::getVar( 'yourfieldname', '', 'post', 'string', JREQUEST_ALLOWHTML );
  /* now proceed as suggested */
 
  $row->bind($data);
  [...] 
  $row->check();
  [...] 
  $row->store();
  [...] 
}
[...]

See also