CKEditor 3.x - New FCKEditor Version
Now FCKEditor is called CKEditor. And here is an running Version of CKEditor and CakePHP.
CKEditor is an WYSIWYG Javascript Editor.
CKEditor is an WYSIWYG Javascript Editor.
To Enable CKEditor functionality in your CakePHP version,
download CKEditor from CKEditors Downloadpage -> http://ckeditor.com/download
Extract the downloaded archive to /app/webroot/js
so that you have the following tree structure
To call CKEditor in a View put this into your *.ctp
An example is:
Reqs:
Javascript helper must be included. ($helpers)
download CKEditor from CKEditors Downloadpage -> http://ckeditor.com/download
Extract the downloaded archive to /app/webroot/js
so that you have the following tree structure
+-/app/webroot/js
+---/ckeditor
+------/images
+------/lang
+------/plugins
+------/skins
+------/themes
Helper Class:
<?php
<?php
class FckHelper extends Helper {
var $helpers = Array('Html', 'Javascript');
function load($id) {
$did = '';
foreach (explode('.', $id) as $v) {
$did .= ucfirst($v);
}
$code = "CKEDITOR.replace( '".$did."' );";
return $this->Javascript->codeBlock($code);
}
}
?>
To call CKEditor in a View put this into your *.ctp
View Template:
<?php
echo $javascript->link('ckeditor/ckeditor', NULL, false);
?>
andView Template:
<?php
echo $fck->load('Model.field');
?>
An example is:
View Template:
<?php
echo $javascript->link('ckeditor/ckeditor', NULL, false);
echo $form->create('News', array('action' => 'edit'));
echo $form->input('title');
echo $form->input('body', array('cols' => '60', 'rows' => '3'));
echo $fck->load('News.body');
echo $form->input('id', array('type'=>'hidden'));
echo $form->end('Save Post');
?>
Reqs:
Javascript helper must be included. ($helpers)








My english level is not good, i hope you know what i need to say.
My boss asked me create ckeditor plugin to reuse it in other application.
and he wants everything about it is contented in app/plugins/flexicore
But the ckeditor source (images,js,css) should storage in webroot/js.
when i try to use it by storage in app/plugins/flexicore/webroot/js and the cksource.php in app\plugins\flexicore\views\helpers.
the browser return error like: require_once(C:\AMP\apache\htdocs\Flexicore\app\webroot\\js\ckeditor\ckeditor.php
Now how can i fix that error?
please helpme. thank all
Isn't CKEditor supposed to work with something like this:
$javascript->link('ckeditor/ckeditor', false);
form->create blah
echo $form->textarea('txt',array('label' => false,'cols'=>'50','rows'=>'3','div'=>false,'class'=>'ckeditor'));
form->end blah
it seems as it's just complicating things to me.
Could someone explain what that helper is actually doing???
@Usman -
No, I have not yet tried to incorporate ckfinder to my cake project.
Currently for image upload, I have another window opened to browse image files uploaded on the server.
Isnt your code sample missing < ? p h p ? > on the last line around "echo $ckfinderPath"?
@Atsushi Yes the php tags are missing as this forum seems to be stripping them. What are you using for image upload?
class AppController extends Controller {
var $components = array('Session');
var $helpers = array('Ajax', 'Javascript', 'Time', 'Form', 'Html', 'Session');
function beforeFilter() {
$ckeditorClass = 'ckeditor';
$this->set('ckeditorClass', $ckeditorClass);
$ckfinderPath = $this->webroot.'js/ckfinder/';
$this->set('ckfinderPath', $ckfinderPath);
}
}
In the view:
echo $form->textarea('content', array('class'=>$ckeditorClass));
?> var editor = CKEDITOR.replace('NewsFeature.content');
CKFinder.SetupCKEditor( editor, ' echo $ckfinderPath ') ;
Any help will be appreciated.
Thanks,
Usman
----------------------------------------------------------class AppController extends Controller {
var $components = array('Menu','Session');
var $helpers = array('Ajax', 'Javascript', 'Time', 'Form', 'Html', 'Session');
function beforeFilter() {
$ckeditorClass = 'ckeditor';
$this->set('ckeditorClass', $ckeditorClass);
$ckfinderPath = $this->webroot.'js/ckfinder/';
$this->set('ckfinderPath', $ckfinderPath);
}
}
view:
<?php
echo $javascript->link('ckeditor/ckeditor.js');
echo $javascript->link('ckfinder/ckfinder.js');
?>
<script type="text/javascript">
var editor = CKEDITOR.replace( 'BlogDesc' ); //html tag #ID
CKFinder.SetupCKEditor( editor, '<?php echo $ckfinderPath ?>') ;
</script>
Great article - how can i include the ckfinder functionality in the code mentioned in the article?
Thanks,
Usman
Helper Class:
<?php
class FckHelper extends Helper {
var $helpers = Array('Html', 'Javascript');
function load($id,$options_=array()) {
$options = array(
'language'=>'it',
'uiColor'=>'#7E9DCC',
'toolbar'=>'Full',
);
if(!empty($options_)) array_merge($options,$options_);
$did = '';
foreach (explode('.', $id) as $v) {
$did .= Inflector::camelize($v);
}
$did = Inflector::humanize($did);
$code = " if (CKEDITOR.instances['".$did."']) {
CKEDITOR.remove(CKEDITOR.instances['".$did."']);
cckeditor".$did.".destroy();
cckeditor".$did." = null;
}\n";
$code .= " cckeditor".$did." = CKEDITOR.replace( '".$did."',".$this->Javascript->object($options).");\n";
return $this->Javascript->codeBlock($code);
}
}
?>
This is my Helkper, I used it in many website attrezzatura subacquea, immersioni, siti web pronti, investimenti immobiliari
Form name = Admin
Field name = content
Controller name = Admins
Modelname = Admin
mycontroller code:
$grn3 = $this->data['Admin']['content'] ;
$this->Session->setFlash($grn3);
$this->Admin->set($this->data ); //setting data to model
$this->Admin->saveField('content', $grn3); //saving single field
Setflash method flashes the data content, but save is not working. I am not sure if this is the way of saving text editor data to database. Please show me how to save editor data to datatbase.
Thankx
John M.
eg, this one:
http://labs.corefive.com/2009/10/30/an-open-file-manager-for-ckeditor-3-0/
I installed it into my cakeapp like this:
http://www.asecondsystem.com/2010/01/19/integrating-a-file-browser-into-ckeditor-cakephp/#more-327
Whats the benefit of the above code? Iv'e plugged this before, but to show what i'm on about:
http://www.asecondsystem.com/2009/09/14/integrating-ck-editor-with-cakephp/
I'm planning to just have a file browser (not uploader) for the images when thats required, so users can select from the images in the sites media folder, which i populate with uploadify elsewhere. (but thats anouther story).
Will
How to integrate CKEditor + CKFinder with Session Authorization into CakePHP --> http://blog.beamstyle.com.hk/?p=170
However, you could at least have mentioned CKFinder, since the file manager is not a part of the core editor anymore.
Also, CKFinder now supports some basic authorization, plus authentication through access to the current session which makes it possible to prevent file uploads by unauthenticated users
It was a very good idea to separate it from the rest of the project. :)
Comments are closed for articles over a year old