Search code examples
phpjoomlatinymcejoomla3.0joomla-component

How to set advanced tinymce in joomla 3 component


I call the editor and it apears, but it's extended version, which is set globaly for admin of whole page, and I want it to stay there that way.

But in my component I want an advance version of tinymce.

Here's code how i call tinymce:

$editor = JFactory::getEditor();
$editor =& JFactory::getEditor('tinymce');
$params = array(
    'mode' => 'advanced'
);
echo $editor->display('opis_long', $this->info['opis_long'], '10', '10', '1', '1', false, $params);

Solution

  • // IMPORT EDITOR CLASS
    jimport( 'joomla.html.editor' );
    
    // GET EDITOR SELECTED IN GLOBAL SETTINGS
    $config = JFactory::getConfig();
    $global_editor = $config->get( 'editor' );
    
    // GET USER'S DEFAULT EDITOR
    $user_editor = JFactory::getUser()->getParam("editor");
    
    if($user_editor && $user_editor !== 'JEditor') {
        $selected_editor = $user_editor;
    } else {
        $selected_editor = $global_editor;
    }
    
    // INSTANTIATE THE EDITOR
    $editor = JEditor::getInstance($selected_editor);
    
    // SET EDITOR PARAMS
    $params = array( 'smilies'=> '0' ,
        'style'  => '1' ,
        'layer'  => '0' ,
        'table'  => '0' ,
        'clear_entities'=>'0',
        'mode' => '1'
    );
    
    // DISPLAY THE EDITOR (name, html, width, height, columns, rows, bottom buttons, id, asset, author, params)
    echo $editor->display('opis_long', $this->info['opis_long'], '400', '400', '20', '20', true, null, null, null, $params);
    

    core code from: How to add joomla editor in custom component view but without using XML form fields?