CKEditor is a text editor used by mostly sites and also under public license. it’s easy to use with php but need more effort to use ckeditor in codeigniter. i am trying to make it simple and sharing what i have done to integrate ckeditor or ckfinder in codeigniter site.
I am using both ckeditor and ckfinder in codeigniter to use images also. we need to include libraries and make controller and need some code to view for done.
Steps:-
1. Download code and extract and upload libraries and js(ckeditor and ckfinder) dir(if you don’t want to use js change path in controller to your uploaded dir)
2. Controller :- create a controller under controllers and add below code :-
Add a function in controller :-
function editor($path,$width) {
//Loading Library For Ckeditor
$this->load->library('ckeditor');
$this->load->library('ckFinder');
//configure base path of ckeditor folder
$this->ckeditor->basePath = base_url().'js/ckeditor/';
$this->ckeditor-> config['toolbar'] = 'Full';
$this->ckeditor->config['language'] = 'en';
$this->ckeditor-> config['width'] = $width;
//configure ckfinder with ckeditor config
$this->ckfinder->SetupCKEditor($this->ckeditor,$path);
}
Add below code in which function you need to add ckeditor :-
$path = '../js/ckfinder';
$width = '850px';
$this->editor($path, $width);
3. View :- add below code to show ckeditor to view and set default value if you want.
<?php echo $this->ckeditor->editor('description',@$default_value);?>
Note :- After set all you need to change image save path
4. Change Image path :- for change image save path you must need to go to “js/ckfinder/config.php”
search for below code and change with your path:-
$baseUrl = '/ci/userfiles/';