[EXTENSION] fckeditor-integration

Thanks!

Now it's working just fine. That [tt]dirname(Yii::app()->basePath)[/tt] seems to be the trick (at least that's all i had to change to get it to work).

Thanks again and also thanks to Ascomae for this great extension.

How to anable optional skin and toolbar mode (basic/default)?

Thanks.

Hello, first of all thank you for your extension :)

I have a little trouble. The editor works fine, but I am trying to load data dynamically with ajax in the fckeditor but I don't know how to select the editor…

Here the way I am trying:

<div class="simple">


<?php echo CHtml::activeLabelEx($cv_texte,'id_cv_sous_categorie'); ?>


<?php echo CHtml::activeDropDownList($cv_texte,'id_cv_sous_categorie',array(''=>''),array( //htmloptions


   'ajax' => array(


      'type'=>'POST',


      'url'=>'index.php?r=cv_texte/loadTexte',


      'update'=>'#cv_texte[texte]',


	),'class'=>'dropDown'));?>


</div>


<div class="simple">


<?php echo CHtml::activeLabelEx($cv_texte,'texte'); ?>


<br/>


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


            'model'     =>  $cv_texte,


            'attribute' => 'texte',


            'height'    =>  '250px',


            'width'     =>  '100%',


            'fckeditor' =>  dirname(Yii::app()->basePath).'/fckeditor/fckeditor.php',


            'fckBasePath' => Yii::app()->baseUrl.'/fckeditor/')


); 


 ?>


</div>

I guess that the javascript in the editor is overwriting the form field selector. Any help is welcome thanks! :)

Since the FCKeditor isn't a simple form-field you'll have to use JS to update it. Luckily, it has an API for this.

First you have to get an instance of the editor, then overwrite (if that's what you want to do, you can append etc also) the data.

Se below for an example. The instance name (FormAddContent[content]) is what you would normally name the form field.

var oEditor = FCKeditorAPI.GetInstance('FormAddContent[content]') ;


oEditor.SetData('<p>Hello World!</p>');

To get the Ajax call to work you need to specify the 'success' field in the ajax error (instead of update/replace). 'success' should point to a js function which takes two parameters: data and status. The data is what you need to feed the editor.

Example time. A snippet from a view:



<?php


$cs = Yii::app()->clientScript;


$cs_id = 'ajaxContentUpdate'; // Must be unique


$cs_script = "


    function update_content(data, status) {


        var oEditor = FCKeditorAPI.GetInstance('FormAddContent[content]');


        oEditor.SetData(data);


    }";


$cs->registerScript($cs_id, $cs_script, CClientScript::POS_READY);


?>




<?php


echo CHtml::activeDropDownList(


    $form,


    'parameter_id',


    CHtml::listData(


        $data, 'id', 'page'), array('ajax' => array(


            'type' => 'POST',


            'url' => 'ajaxGetContent',


            'success' => 'update_content'


));


Hi, i just added 2 lines of Code for the Customization of the Toolbar:

views/fCKEditorWidget.php:



$oFCKeditor->ToolbarSet = $toolbarSet;


fCKEditorWidget.php:



public $toolbarSet;





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


      "fckBasePath"=>$this->fckBasePath,


      "fckeditor"=>$this->fckeditor,


      "model"=>$this->model,


      "attribute"=>$this->attribute,


      "height"=>$this->height,


      "width"=>$this->width,


      "toolbarset"=>$this->toolbarSet, // <- this one


      "config"=>$this->config,


    ));





Usage example:



 $this->widget('application.extensions.fckeditor.FCKEditorWidget',array(


            'model'     =>  $post,


            'attribute' => 'content',


            'height'    =>  '500px',


            'width'     =>  '100%',


            'fckeditor' =>  dirname(Yii::app()->basePath).'/../fckeditor/fckeditor.php',


            'fckBasePath' => Yii::app()->baseUrl.'/../fckeditor/',


            'toolbarset' => 'Basic', // <-- set your toolbar here as defined in  fckeditor.js  


            'config' => array("DefaultLanguage" => "de",)


Works fine for me, thank you for this extension so far.

Will you implement support for CKeditor 3 (beta2) - this seems to be somewhat different…

@thyseus

I following your codes, but I get error like this: Property “FCKEditorWidget.toolbarset” is not defined.

How to fix this?

Yii: v1.0.4

FckEditor: v2.6.4

Upss… just make all $toolbarset to be $toolbarSet;

Now… how to changes the skin?

Great extension, but how can I have more than 1 editor in a form? Seems like the second editor isn't rendered. Only a normal textarea appears.

Quote

Great extension, but how can I have more than 1 editor in a form? Seems like the second editor isn't rendered. Only a normal textarea appears.

This behaviour isn´t normal. I have got 2 fckeditors in one form without problems…

Sorry for my long absence.

I’ve just released version 0.0.4. In that version I’ve included the support for the ToolbarSet. (Thank to thyseus, I’ve nearly used your code)

It is possible to use a predefined toolbar (see fckconfig.js). It i not possible to configure a toolbar dynamicly.

Christian

Quote

Great extension, but how can I have more than 1 editor in a form? Seems like the second editor isn't rendered. Only a normal textarea appears.

I think the integration does only support datamodels. You can use more than one editor at on page. But you have to make sure, that every editor has it own ID.

The ID will bee created like this:

Model[Attribute]

For instance:

You created a Model called "User" with an attribute "Comment".

The generated ID will be:

User[Comment]

If you edit more than one Object of the Same Model you will get into troble, because the Id's may not be unique.

Summery

  • It is possible to edit more than one Attribute at one page
  • It is possible to edit more than one Model at one page
  • It is not possible to edit more than one Instance of an model at one page

Christian

PS:






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


"model"=>$pages,


"attribute"=>'content',


"height"=>'400px',


"width"=>'100%',


"fckeditor"=>Yii::app()->basePath."/../fckeditor/fckeditor.php",


"fckBasePath"=>Yii::app()->baseUrl."/fckeditor/",


"config" => array("EditorAreaCSS"=>Yii::app()->baseUrl.'/css/index.css',),


) ); ?>








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


"model"=>$pages,


"attribute"=>'discription', #Attribute in the Model


"height"=>'400px',


"width"=>'100%',


"fckeditor"=>Yii::app()->basePath."/../fckeditor/fckeditor.php",


"fckBasePath"=>Yii::app()->baseUrl."/fckeditor/",


"toolbarSet"=>"Basic",     	#EXISTING(!) Toolbar (see: fckeditor.js)


"config" => array(


	"EditorAreaCSS"=>Yii::app()->baseUrl.'/css/index.css',


),


) ); ?>





will work

I’m still waiting for skin option add on this extension.

Have you tried to set:

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


"model"=>$pages,


"attribute"=>'content',


"height"=>'400px',


"width"=>'100%',


"fckeditor"=>Yii::app()->basePath."/../fckeditor/fckeditor.php",


"fckBasePath"=>Yii::app()->baseUrl."/fckeditor/",


"config" => array(


"EditorAreaCSS"=>Yii::app()->baseUrl.'/css/index.css',


"SkinPath"=>'<valid_skin_path>',


),


) ); ?>

Look at:

"SkinPath"=>'<valid_skin_path>',

Nearly every parameter from http://docs.fckedito…uration_Options should be able to be set.

Christian

I'm following your example like this:



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


	"model"=>$content,


	"attribute"=>'content',


	"height"=>'200px',


	"width"=>'700px',


	"fckeditor"=>Yii::app()->basePath."/../fckeditor/fckeditor.php",


	"fckBasePath"=>Yii::app()->baseUrl."/fckeditor/",


	"toolbarSet" => 'Default',


	"config" => array(


		"EditorAreaCSS"=>Yii::app()->baseUrl.'/css/index.css',


		"SkinPath" => "C:/www/webapp/fckeditor/editor/skins/silver",


		),


) ); ?>


But it make the toolbar sets (image/icons) is gone…

If I change

“SkinPath”
to
“skinPath”
, the toolbar sets is back but in default skin.

Seems to be a configuration-issue.

Your specified path is wrong.

It has to be a relative Path like "/fckeditor/2.6.4/editor/skins/office2003/" for Instance.

Christian

PS:

It's not an Issue in the integration-extension itself.

I also tried like this:

"SkinPath" => Yii::app()->baseUrl.'/skins/silver/',
,

because the skins root folder it same level with css folder in

"EditorAreaCSS"=> Yii::app()->baseUrl.'/css/index.css',
.

But it not work.

Anyway thanks you Christian…

Maybe anyone here have successful using this option?



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


"model"=>$pages,


"attribute"=>'discription', #Attribute in the Model


"height"=>'400px',


"width"=>'100%',


"fckeditor"=>Yii::app()->basePath."/../fckeditor/fckeditor.php",


"fckBasePath"=>Yii::app()->baseUrl."/fckeditor/",


"toolbarSet"=>"Basic",     	#EXISTING(!) Toolbar (see: fckeditor.js)


"config" => array(


	"EditorAreaCSS"=>Yii::app()->baseUrl.'/css/index.css',


	"SkinPath"=>Yii::app()->baseUrl."/fckeditor/editor/skins/silver/"


),


) ); ?>


In my configuration the example above works.

Be careful. You have to set the trailing "/".

The paths in your application may differ.

Christian

:D Hi, I just Copy-Paste your code… and it works…

Thanks you Christian…

Hello,

how about insert image feature Christian

Best regards,