Search code examples
yiickeditor

Install ckeditor in YII framework


I am using Yii Framework version 1.1.14. I am able to install FCK editor but I want to use ck editor.

I download files from this links http://www.yiiframework.com/extension/the-ckeditor-integration/ and upload files on location but i get this error check image

I am using this code in my view

<?php $this->widget('application.extensions.ckeditor.CKEditorWidget',array(
    'model'=>$model,                # Data-Model (form model)
    'attribute'=>'content',         # Attribute in the Data-Model
    'height'=>'400px',
    'width'=>'100%',
    'toolbarSet'=>'Basic',          # EXISTING(!) Toolbar (see: ckeditor.js)
    'ckeditor'=>Yii::app()->basePath.'/../ckeditor/ckeditor.php',
                                    # Path to ckeditor.php
    'ckBasePath'=>Yii::app()->baseUrl.'/ckeditor/',
                                    # Relative Path to the Editor (from Web-Root)
    'css' => Yii::app()->baseUrl.'/css/index.css',
                                    # Additional Parameters
) ); ?>

Solution

  • Download CKEditor from http://ckeditor.com/download (Select full package) and put it in your root directory (You can put it any where according to you)

    Add this is your view file

    <script src="<?php echo Yii::app()->baseUrl.'/ckeditor/ckeditor.js'; ?>"></script>
    
    
    <script type="text/javascript">
        CKEDITOR.replace( 'Articles_meta_description');
    </script>
    

    Where Articles_meta_description is id of input fields

    If you want add image upload in ckeditor you can download KCfinder from this link http://kcfinder.sunhater.com/download and put it in your root directory (you can put it any where according to you)

    Set upload path into session : in your view file

    $_SESSION['KCFINDER']['disabled'] = false; // enables the file browser in the admin
    $_SESSION['KCFINDER']['uploadURL'] = Yii::app()->baseUrl."/uploads/"; // URL for the uploads folder
    $_SESSION['KCFINDER']['uploadDir'] = Yii::app()->basePath."/../uploads/"; //
    

    For ckeditor with image upload

    <script type="text/javascript">
        CKEDITOR.replace( 'Articles_meta_description', {  // input field id
             filebrowserBrowseUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/browse.php?type=files',
             filebrowserImageBrowseUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/browse.php?type=images',
             filebrowserFlashBrowseUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/browse.php?type=flash',
             filebrowserUploadUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/upload.php?type=files',
             filebrowserImageUploadUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/upload.php?type=images',
             filebrowserFlashUploadUrl: '<?php echo Yii::app()->baseUrl; ?>/kcfinder/upload.php?type=flash'
        });
    </script>