Yii 1.1: nh-ckeditor

Just another CKEditor extension
5 followers

Another CKEditor extension that uses the parameters based on CKEditor API.

-- Changes in version 0.1 --

  • Fix errors when using array as value in editorOptions
  • Add support for javascript code in editorOptions

Resources

Documentation

Requirements

  • Yii 1.0.5 or above

Installation

  • Extract the release file under protected/extensions

Usage

See the following code example:

$this->widget(
    'application.extensions.NHCKEditor.CKEditorWidget', 
    array(
        //  [Required] CModel object
        'model' => $model,
        'attribute' => 'ATTRIBUTE_NAME',
 
        //  [Optional] CSS file to be included
        'cssFile' => Yii::app()->request->baseURL.'/css/YOUR_FILE.css',
 
        //  [Optional] Options based on CKEditor API documentation
        'editorOptions' => array(
 
            //  Now supports PHP array and javascript code (must begin with js:)
 
            //'width' => 800,
            //'height' => 480,
            //'language' => 'th',
 
 
            //'toolbar' => 'Full',              //  format #1:  String
 
            //'toolbar' => array(               //  format #2:  PHP array
            //  array('Source', '-', 'Save')
            //),
 
            //'toolbar' => "js:[                //  format #3:  javascript code
            //  ['Source', '-', 'Save']
            //]",
 
            //'uiColor' => '',
 
            //  ... your own options
        ),
 
        //  [Optional] htmlOptions based on Yii implementation
        'htmlOptions' => array(
            //
        ),
    )
);

Change Log

December 18, 2009

  • Fix an error when using array as value in editorOptions (thanks @gazbond for his comment)
  • Add support for javascript code in editorOptions

November 2, 2009

  • Initial release. v0.1b

Total 8 comments

#4516 report it
gallego123 at 2011/07/15 10:53am
SOLVED ReadOnly Editor
  1. download last version ckeditor http:ckeditor.com/download
  2. replace folder assets with new version
  3. use property readOnly
...
'editorOptions' => array(
...
            'width' => 500,
...   
            'readOnly'=>true/false, // here !!!!!!
#4514 report it
gallego123 at 2011/07/15 10:17am
Enable disable editor

Hi

who enable or disable editor?

i pass html_options array('readonly'=>'readonly') but not work

#4157 report it
Vedran at 2011/06/10 05:31am
Configuration of uploading folder

Hello, thanks for this very good and useful extension. I use it to combine CKEditor and CKFinder, I only pass path to CKFinder script bellow "// ... your own options" line.

However, is there any option to configure where images and other will be uploaded by CKFinder? In CKFinder main configuration, there is one properity $baseUrl where you can do that. Default is '/ckfinder/userfiles/'.

However, that confiuration script does not understand Yii coined urls like Yii::app()->baseUrl; and similar. Also, I don't like to mess up with this config script, especially if I'll use it for several webpages.

So, is there any possibility to set this from widget? Does anyone have experience with this?

#244 report it
Timbo at 2010/07/28 05:37pm
Visibility of properties must be public

In order for this widget to work with 1.1.3, the visibility of the protected properties ($editorOptions, etc) of CKEditorWidget must be changed from protected to public.

#316 report it
kazio at 2010/07/12 02:45am
1.1.3

it does not works with 1.1.3 properity editorOptions is not defined.

#473 report it
toMeloos at 2010/05/21 05:02am
Usage with CActiveForms

CKEditor also works in combination with Ajax, e.g. a CActiveForm. For more information:

Forum topic on CKEditor with CActiveForm

#1077 report it
PoohOka at 2009/12/17 06:25am
will be fixed soon

@gazbond thanks for your help. I'll fix this in the next version.

#1090 report it
gazbond at 2009/12/11 07:39am
Does not pass nested arrays or JSON strings

You cannot configure like:


'editorOptions'=>array(
   'toolbar'=>array(
      array('Styles', 'Format'),
      array('Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', '-', 'About')
   )
),
Or like:

'editorOptions'=>array(
   'toolbar'=>"[
      ['Styles', 'Format'], 
      ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', '-', 'About']
   ]"
),
The first produces the following javascript:

toolbar: Array
And the second:

toolbar: '[
      ['Styles', 'Format'], 
      ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', '-', 'About']
   ]'
Notice the leading single quote.
I think you should add the following to CKEditorWidget->jsOptions():

else
{
   $value = CJSON::encode($value); // add this
   $jsObject .= "\t".$name.": {$value},\r\n";
}
You can then use php arrays.

Leave a comment

Please to leave your comment.

Create extension