Integration of CKEditor editor in CI framework tutorial _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.