CKEditor in CodeIgniter

匿名 (未验证) 提交于 2019-12-03 00:56:02

问题:

I wanna load CKEditor in CodeIgniter,I search a lot,but can't understand their way.

I placed ckeditor in application/plugins folder and now I wanna make editor ,so I do following in Controller Method.

include APPPATH.'plugins/ckeditor/ckeditor.php'; $CKEditor = new CKEditor(); $CKEditor->basePath = '/'.APPPATH.'plugins/ckeditor/'; $initialValue = '

This is some sample text.

'; echo $CKEditor->editor("editor1", $initialValue);

but it makes simple teaxaria only ,with

This is some sample text.

value. where is the problem and how should I solve it?

回答1:

I use this steps to add ckeditor to my codeigniter apps:

1) Download these files:

2) Copy the files you just downloaded into your Application/libraries folder

3) Download the ckeditor helper here: http://pastebin.com/Cd3GqYbx

4) Copy the last file in application/helper folder as ckeditor_helper.php

5) Download the CKeditor controller here: http://pastebin.com/UD0bB9ig

6) Copy the controller in your application/controllers folder as ckeditor.php

7) Download the main ckeditor project from the official site: http://ckeditor.com/download/

8) Copy the ckeditor folder you just download into your asset folder (if you want you can also download the ckfinder project and put it in the same folder)

9) Add these line of js to your view file (adjust the path):

  

10) In your controller add this php code and adjust the path:

$this->load->library('ckeditor'); $this->load->library('ckfinder');    $this->ckeditor->basePath = base_url().'asset/ckeditor/'; $this->ckeditor->config['toolbar'] = array(                 array( 'Source', '-', 'Bold', 'Italic', 'Underline', '-','Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo','-','NumberedList','BulletedList' )                                                     ); $this->ckeditor->config['language'] = 'it'; $this->ckeditor->config['width'] = '730px'; $this->ckeditor->config['height'] = '300px';              //Add Ckfinder to Ckeditor $this->ckfinder->SetupCKEditor($this->ckeditor,'../../asset/ckfinder/');  

11) In your view print the editor with:

echo $this->ckeditor->editor("textarea name","default textarea value"); 


回答2:

You could otherwise do this:

  1. copy the CKEditor files to a folder in your source's root eg ckeditor
  2. Include the CKEditor files in your view file

              
  3. finally your textarea in your html document

     
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!