1

I'm trying to display an editor using a module in the front end. I want visitors to be able to edit and create articles but from a module not a component.

I've tried:

jimport( 'joomla.html.editor' );
$editor =& JEditor::getInstance();
echo $editor->display("desc", "my text", "600", "400", "80", "15",1);

which I think should work but doesn't (I've tried with all the versions of editors installed). Any help would be great.

1
  • I just want to leave a non-resolving, academic note that in accordance with PSR-12, no php application should ever use =& as a combined operator, because it is not a combined operator. If you are a developer that is careful about every character in your script, have a read of this: stackoverflow.com/a/63914758/2943403 It is simple to fix by doing a project-wide search&replace through your IDE. Mar 29, 2021 at 21:43

1 Answer 1

1

I solved my problem

echo JHtml::_('form.csrf');

    jimport( 'joomla.html.editor' );
    
    $config = JFactory::getConfig();
    $global_editor = $config->get( 'editor' );
    
    $user_editor = JFactory::getUser()->getParam("editor");
    
    if($user_editor && $user_editor !== 'JEditor') {
        $selected_editor = $user_editor;
    } else {
        $selected_editor = $global_editor;
    }
    
    $editor = JEditor::getInstance($selected_editor);
    
    $editor_params = array( 'smilies'=> '0' ,
        'style'  => '1' ,
        'layer'  => '0' ,
        'table'  => '0' ,
        'clear_entities'=>'0',
        'mode' => '1',
        'buttons' => 0
    );

echo "<form> ";
    echo $editor->display('editMain', '', '100%', '400', '20', '20', true, null, null, null, $editor_params);
echo JHtml::_( 'form.token' );
 //echo '<input id="token" type="hidden" name="' . JSession::getFormToken($forceNew = true) . '" value="1" />';

echo "</form>";

This works . I was had placed the csfr in the wrong place and once it was in the right place all worked as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.