HowTo integrate the FCKEditor

Hi,

if you want to integrate the FCKEditor into a Yii you can do it like this:

You need a Widget:

/protected/components/FCKEditorWidget.php



<?php


class FCKEditorWidget extends CInputWidget


{


// Content will be read from  $this->model->$this->field;


	public $model;


	public $property;


	public $height = "375px";


	public $width = "100%";





	public function run()


	{


		$controller=$this->controller;


		$action=$controller->action;


		$this->render('fCKEditorWidget',array(





			"model"=>$this->model,


			"property"=>$this->property,


			"height"=>$this->height,


			"width"=>$this->width,


		));


	}


}


?>


a View:

/protected/components/views/fCKEditorWidget.php



<?php


require_once(Yii::app()->basePath."/../fckeditor.php");





$oFCKeditor = new FCKeditor(get_class($model).'['.$property.']');


$oFCKeditor->BasePath = Yii::app()->baseUrl."/";


$oFCKeditor->Value = $model->$property;


$oFCKeditor->Width  = $width ;


$oFCKeditor->Height = $height ;


$oFCKeditor->EditorAreaCSS = Yii::app()->baseUrl.'/css/index.css';


$oFCKeditor->Create();


?>


and a page using it:



<?php echo CHtml::activeLabel($pages,'content'); ?>





<?php $this->widget('application.components.FCKEditorWidget',array(


"model"=>$pages,


"property"=>'content',


"height"=>'400px',


"width"=>'100%'


) ); ?>


To use this Code, the FCKEdior have to be placed into the webRoot of your application. 

Should this be an Extension in the "extension" Directory? I placed these Files into "protectd/components" Folder.

Regards,

Christian

Good job!

Yes, you can distribute this as an extension. If that is the case, you should assume that the extension would be installed under protected/extensions/fckeditor

I made an extension and submitted itto the extension-Repository.

http://www.yiiframew…or-integration/

I startet a googlecode Project

http://code.google.c…or-integration/

Christian

What’s up with the broken links I keep finding in posts?

Hi,

I am new to YII

i had used your code as you had said.

but i am getting an error and i am unable to configure it, error description is given below

require_once(C:\wamp\www\gmat\protected\…\FCKEditor.php) [<a href=‘function.require-once’>function.require-once</a>]: failed to open stream: No such file or directory

then i have changed the path as

require_once(C:\wamp\www\gmat\protected\components\FCKEditor.php) [<a href=‘function.require-once’>function.require-once</a>]: failed to open stream: No such file or directory

Please Help

Thanks in Advamce