CodeIgniter中的CKEditor

Moe*_*ini 7 javascript php codeigniter ckeditor

我想在CodeIgniter中加载CKEditor,我搜索了很多,但无法理解他们的方式.

我将ckeditor放在application/plugins文件夹中,现在我想编辑器,所以我在Controller Method中做了以下操作.

include APPPATH.'plugins/ckeditor/ckeditor.php';
$CKEditor = new CKEditor();
$CKEditor->basePath = '/'.APPPATH.'plugins/ckeditor/';
$initialValue = '<p>This is some <strong>sample text</strong>.</p>';
echo $CKEditor->editor("editor1", $initialValue);
Run Code Online (Sandbox Code Playgroud)

但它只使用简单的teaxaria

This is some sample text.

值.问题在哪里,我该如何解决?

Chr*_*oni 29

我使用此步骤将ckeditor添加到我的codeigniter应用程序:

1)下载这些文件:

  • 这适用于Ckeditor:http://pastebin.com/fkK9e0RR
  • 这适用于Ckfinder:http://pastebin.com/SvyypmX4

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文件夹复制到资产文件夹中(如果需要,也可以下载ckfinder项目并将其放在同一个文件夹中)

9)将这些js行添加到视图文件中(调整路径):

<script type="text/javascript" src="/asset/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/asset/ckfinder/ckfinder.js"></script>
Run Code Online (Sandbox Code Playgroud)

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/'); 
Run Code Online (Sandbox Code Playgroud)

11)在您的视图中打印编辑器:

echo $this->ckeditor->editor("textarea name","default textarea value");
Run Code Online (Sandbox Code Playgroud)

  • 如何添加图片上传功能?在$ config ['toolbar']中添加了图片,但它不起作用.请帮忙 (2认同)