Integration of the CKEditor editor in the CI framework. 1. add the fckeditor directory to CI_PATHsystemplugins2, add $ config [fckeditor_basepath] systempluginsfckeditor to ci_pathsystemapplins2, and add the fckeditor directory to CI_PATH/system/plugins/
2. add the following to CI_PATH/system/application/config. php:
$ Config ['fckeditor _ basepath'] = "/system/plugins/fckeditor /";
$ Config ['fckeditor _ toolbarset_default '] = 'default ';
3. create helper and create form_helper.php in/system/application/helpers
The code is as follows:
If (! Defined ('basepath') exit ('no direct script access allowed ');
Include_once (BASEPATH. '/helpers/form_helper'. EXT );
Function form_fckeditor ($ data = '', $ value ='', $ extra = '')
{
$ CI = & get_instance ();
$ Fckeditor_basepath = $ CI-> config-> item ('fckeditor _ basepath ');
Require_once ($ _ SERVER ["DOCUMENT_ROOT"]. $ fckeditor_basepath. 'fckeditor. php ');
$ InstanceName = (is_array ($ data) & isset ($ data ['name'])? $ Data ['name']: $ data;
$ Fckeditor = new FCKeditor ($ instanceName );
If ($ fckeditor-> IsCompatible ())
{
$ Fckeditor-> Value = html_entity_decode ($ value );
$ Fckeditor-> BasePath = $ fckeditor_basepath;
If ($ fckeditor_toolbarset = $ CI-> config-> item ('fckeditor _ toolbarset_default '))
$ Fckeditor-> ToolbarSet = $ fckeditor_toolbarset;
If (is_array ($ data ))
{
If (isset ($ data ['value'])
$ Fckeditor-> Value = html_entity_decode ($ data ['value']);
If (isset ($ data ['basepath'])
$ Fckeditor-> BasePath = $ data ['basepath'];
If (isset ($ data ['toolbarset'])
$ Fckeditor-> ToolbarSet = $ data ['toolbarset'];
If (isset ($ data ['width'])
$ Fckeditor-> Width = $ data ['width'];
If (isset ($ data ['height'])
$ Fckeditor-> Height = $ data ['height'];
}
Return $ fckeditor-> CreateHtml ();
}
Else
{
Return form_textarea ($ data, $ value, $ extra );
}
}
?>
4. use fckeditor in the project
The code is as follows:
$ This-> load-> helper ('form _ helper ');
$ Data = array (
'Name' => 'newscontent ',
'Id' => 'newscontent ',
// 'Toolbarset' => 'advanced ',
'Basepath' => $ this-> config-> item ('fckeditor _ basepath '),
'Width' => '123 ',
'Height' => '123'
);
Echo form_fckeditor ($ data );
?>
Protocol 2, in CI_PATH/system/application/config. add $ config ['fckeditor _ basepath'] = "/system/plugins/fckeditor/"; $ c...