我使用以下步骤将 ckeditor 添加到我的 codeigniter 应用程序中:
1) 下载这些文件:
2) 将刚刚下载的文件复制到Application/libraries文件夹中
3) 在此处下载 ckeditor 助手:http: //pastebin.com/Cd3GqYbx
4) 将application/helper文件夹中的最后一个文件复制为ckeditor_helper.php
5)在这里下载CKeditor控制器:http: //pastebin.com/UD0bB9ig
6) 将您的应用程序/控制器文件夹中的控制器复制为ckeditor.php
7)从官网下载ckeditor主工程:http: //ckeditor.com/download/
8) 将刚才下载的ckeditor文件夹复制到asset文件夹中(如果需要也可以下载ckfinder工程放在同一个文件夹下)
9)将这行js添加到您的视图文件中(调整路径):
<script type="text/javascript" src="/asset/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/asset/ckfinder/ckfinder.js"></script>
10) 在您的控制器中添加此 php 代码并调整路径:
$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) 在您看来,使用以下命令打印编辑器:
echo $this->ckeditor->editor("textarea name","default textarea value");