jmestral
(Jmoreno)
January 24, 2018, 1:38pm
1
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!
owais.ali
(Owais Ali)
January 25, 2018, 5:25am
2
jmestral:
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.
jmestral
(Jmoreno)
January 25, 2018, 10:52am
3
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']);
?>
jmestral
(Jmoreno)
January 29, 2018, 8:45am
4
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