This extension helps you to integrate CKEditor (next generation of FCKEditor) in your Yii application.

Note that CKEditor is not included in this extension, You can Download CKEditor form its official site and use it with this extension in your applications.
protected/extensionsSee the following code example:
$this->widget('ext.ckeditor.CKEditorWidget',array( "model"=>$pages, # Data-Model "attribute"=>'content', # Attribute in the Data-Model "defaultValue"=>"Test Text", # Optional # Additional Parameter (Check http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html) "config" => array( "height"=>"400px", "width"=>"100%", "toolbar"=>"Basic", ), #Optional address settings if you did not copy ckeditor on application root "ckEditor"=>Yii::app()->basePath."/../ckeditor/ckeditor.php", # Path to ckeditor.php "ckBasePath"=>Yii::app()->baseUrl."/ckeditor/", # Realtive Path to the Editor (from Web-Root) ) );
if you need full details of configuration parameters, please visit CKEditor API.
Total 15 comments
It is a good extension. Thanks
I use a form with model array.
The widget render:
PagesLang[[1][pgtext]]But I need:
PagesLang[1][pgtext]Because my controller works:
I can modify ext/view/CKEditorView.php to:
I don't know it is good or not, but works...
I've tried a bunch of extentsions on this site, many is awesome but this one Is flawless. Simple and powerfull:) I've not had a single problem with this on the entire time. I just create new crud operations with gii and my textareas becomes powerfull ck editors instead:)
I've had it installed for a while but its not until now when I'm fixing the individuall text formatting / looks on 20+ pages with text that I realise how awesome it is to have it installed.
Hi,
Nice wrap. Is there a upload ext. which works with this?
Hi, is there a way to add a second CKeditor window, loaded through ajax with its own save button (ajax save - different model) ?
i'm pulling my hair out and can't make it work. the ckeditor window loads just ok and loads the neccessary data (it's filled with content correctly) but when i hit SAVE, the new ckeditor window content is not saved. when iswitch back to a normal form, it's saved as it should.
anyone went through something like this?
indeed, the Widget should do (line 73):
@swiftgaruda: check out this post http://www.yiiframework.com/forum/index.php?/topic/9341-ckeditor-widget-in-a-cactiveform/
I had to set the value of the model attribute to the defaultvalue:
I'm using latest Yii 1.1.7 and [url="http://www.yiiframework.com/extension/ckeditor-integration"]ckeditor-integration[/url]. I setup ckeditor as per the directions on the extension page =>
[code] <?php $base = Yii::app()->request->baseUrl; $this->widget('ext.ckeditor.CKEditorWidget', array( "model"=>$event, "attribute"=>'description', 'config'=>array( 'width'=>'600px', 'filebrowserBrowseUrl' => $base.'/filemanager/index.html', ), )); ?> [/code]
But when the editor loads, the attribute doesn't come up.
I patched extensions/ckeditor/views/CKEditorView.php to make it work =>
keditor/views/CKEditorView.php 44a45,48
[b]Did I miss something?[/b]
I submit this as a patch on the ext, but I'm still too green around the ears.
Thanks in advance, Daniel
I'm using latest Yii 1.1.7 and [url="http://www.yiiframework.com/extension/ckeditor-integration"]ckeditor-integration[/url]. I setup ckeditor as per the directions on the extension page =>
[code] <?php $base = Yii::app()->request->baseUrl; $this->widget('ext.ckeditor.CKEditorWidget', array( "model"=>$event, "attribute"=>'description', 'config'=>array( 'width'=>'600px', 'filebrowserBrowseUrl' => $base.'/filemanager/index.html', ), )); ?> [/code]
But when the editor loads, the attribute doesn't come up.
I patched extensions/ckeditor/views/CKEditorView.php to make it work =>
keditor/views/CKEditorView.php 44a45,48
[b]Did I miss something?[/b]
I submit this as a patch on the ext, but I'm still too green around the ears.
Thanks in advance, Daniel
hi ddreggors,
the place is exactly in a view page. but before rendering the view, you should bind it with a model in your controller.
for example you some code like following in your controller:
$model = Pages::model()->findByPk(1);
$this->render('index', array(
'pages' => $model,
));
by this code, you will pass a model in the name of pages to your view/index file. I assumed that you have a field called content in your model which will be used in widget. If you want to use any other name, please edit your widget configuration.
Cheers
I have the CKEditor extracted to my servers web root, and this extension extracted in my protected/extensions folder. Now if I use the code above I get the following Yii error:
Undefined variable: pages
and it has a reference to the code:
My question is, where are you supposed to place your code example above. In my attempt I placed your exact code in my index view on a new test site. Is a view the wrong place?
If this is supposed to be in a view, then what went wrong here?
Hmm. Patch is broken by parser. URL of patch: http://dl.dropbox.com/u/6312269/CKEditorView.php.patch
Hello. It's wrong to create attribute name as: get_class($model).'['.$attribute.']' It works wrong for complex forms with arrays as attributes. Yii way of doing that is: CHtml::resolveName($model, $attribute).
So the patch is:
--- CKEditorView.orig.php 2011-01-16 00:03:32.000000000 +0300 +++ CKEditorView.php 2011-01-16 00:05:02.000000000 +0300 @@ -33,7 +33,7 @@
require_once($ckEditor);
-$oCKeditor = new CKeditor(get_class($model).'['.$attribute.']'); +$oCKeditor = new CKeditor(CHtml::resolveName($model, $attribute)); $oCKeditor->basePath = $ckBasePath;
if(isset($config) && is_array($config)){ @@ -42,5 +42,5 @@ if(isset($config) && is_array($config)){ } }
-$oCKeditor->editor(get_class($model).'['.$attribute.']',$defaultValue); +$oCKeditor->editor(CHtml::resolveName($model, $attribute),$defaultValue); ?> \ No newline at end of file
Hello Paulie,
I recommend to put the Ckeditor in your web-root (in your server it seems to be in www). If you put any code in your protected folder, it can be accessible only from Yii framework and you can not refer to it as an external code.
If you like to put your Ckeditor in any other folder (any where instead of protected folder) you can set the address using ckBasePath attribute.
Hi,
Could you advise where the ckeditor should be deployed to? The only way I can get this to work is to put ckeditor in "www" AND "www/protected". If I put ckeditor in just www or www/protected various include directives fail.
Thanks,
Paul.
Leave a comment
Please login to leave your comment.