CKEditor + Responsive Filemanager on YII2

Hello!

I’m starting to develop in Yii2 and I’m trying to use CKEditor with Responsive Filemanager.

If I only use CKEditor, it works fine:




<?= 


use dosamigos\ckeditor\CKEditor;


$form->field($model, 'tiposnoticia_descripcion')->widget(CKEditor::className(), ['preset' => 'basic']); 

	

?>



But I can’t get CKEditor and Responsive Filemanager to work togheter.

CKEditor was installed with composer.

Does anyone know how to do it?

Thanks a lot! ;)

There is a typo in the code you mentioned. You should use php long tag in the beginning i.e. ‘<?php’ which ends with ‘?>’.

Or you can use php echo tag ‘<?=’ only with the statement when you want to display it. In your case, you can use it before form-fields but you cannot use it before use statements.

Thanks

Actually, I have this:




<?php


use yii\helpers\Html;

use yii\widgets\ActiveForm;

use dosamigos\ckeditor\CKEditor;


?>


<div class="tiposnoticias-form">


    <?php $form = ActiveForm::begin(); ?>


<?= 

    $form->field($model, 'tiposnoticia_descripcion')->widget(CKEditor::className(), 

    ['preset' => 'basic']); 

?>

	

	



I found a package of CKEditor that includes Responsive Filemanager plugin here:

https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=32261&filter_member=tmtung144

Calling both plugins .js and replacing a textarea by CKEditor it was easy:




<?php


use yii\helpers\Html;

use yii\widgets\ActiveForm;

use dosamigos\ckeditor\CKEditor;


$this->registerJsFile(

    '@web/assets/js/filemanager/javascript/ckeditor/ckeditor.js',

    ['depends' => [\yii\web\JqueryAsset::className()]]

);


$this->registerJsFile(

    '@web/assets/js/filemanager/javascript/filemanager.js',

    ['depends' => [\yii\web\JqueryAsset::className()]]

);


/* @var $this yii\web\View */

/* @var $model backend\models\Tiposnoticias */

/* @var $form yii\widgets\ActiveForm */

?>


<div class="tiposnoticias-form">


    <?php $form = ActiveForm::begin(); ?>

 

    <?= $form->field($model, 'tiposnoticia_descripcion')->textarea(['rows' => 6]); ?>


<?php

      $this->registerJsFile(

        '@web/assets/js/filemanager/javascript/replacer.js',

        ['depends' => [\yii\web\JqueryAsset::className()]]

    );

    ?>


    <div class="form-group">

        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

    </div>


    <?php ActiveForm::end(); ?>


</div>




Here, I replace the textarea "tiposnoticia_descripcion" using replacer.js:




 CKEDITOR.replace( 'tiposnoticias-tiposnoticia_descripcion' ,{

    filebrowserBrowseUrl : '/advanced/backend/web/assets/js/filemanager/javascript/filemanager/dialog.php?type=2&editor=ckeditor&fldr=',

    filebrowserUploadUrl : '/advanced/backend/mestral/advanced/backend/web/assets/js/filemanager/javascript/filemanager/dialog.php?type=2&editor=ckeditor&fldr=',

    filebrowserImageBrowseUrl : '/advanced/backend/web/assets/js/filemanager/javascript/filemanager/dialog.php?type=1&editor=ckeditor&fldr='

});



I hope this can help you :P