CodeIgniter中的CKEditor [英] CKEditor in CodeIgniter

查看:121
本文介绍了CodeIgniter中的CKEditor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在CodeIgniter中加载CKEditor,我搜索了很多,但是不能理解他们的方式。



我把ckeditor放在 application / plugins 文件夹,现在我想编辑器,所以我在Controller方法中执行下面的操作。

 包括APPPATH.'plugins / ckeditor / ckeditor.php'; 
$ CKEditor = new CKEditor();
$ CKEditor-> basePath ='/'APAPATH.'plugins/ckeditor/';
$ initialValue ='< p>这是一些< strong>示例文本< / strong>。
echo $ CKEditor-> editor(editor1,$ initialValue);

但它只是简单的水稻,

这是一些示例文本

值。
其中是问题,我该如何解决它?

解决方案

我使用这个步骤添加ckeditor到我的codeigniter apps:



1)下载这些文件:





2)复制档案您刚刚下载到应用程序/库文件夹中



3)在此处下载ckeditor助手: http://pastebin.com/Cd3GqYbx



4)复制 application / helper ckeditor_helper.php



5)在此处下载CKeditor控制器: http://pastebin.com/UD0bB9ig



6)将 application / controllers 文件夹中的控制器复制为 ckeditor.php



7)从官方网站下载主要ckeditor项目: http://ckeditor.com/download/



8)将刚刚下载的ckeditor文件夹复制到资产文件夹中(如果您愿意,可以还可以下载ckfinder项目并将其放在同一个文件夹中)



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

 < script type =text / javascriptsrc =/ asset / ckeditor / ckeditor.js>< / script& 
< script type =text / javascriptsrc =/ 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';

//将Ckfinder添加到Ckeditor中
$ this-> ckfinder-> SetupCKEditor($ this-> ckeditor,'.. / .. / asset / ckfinder /');

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

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


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 = '<p>This is some <strong>sample text</strong>.</p>';
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?

解决方案

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):

<script type="text/javascript" src="/asset/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/asset/ckfinder/ckfinder.js"></script>

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");

这篇关于CodeIgniter中的CKEditor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆