-
Notifications
You must be signed in to change notification settings - Fork 7.6k
CKEditor
Please note that the wiki tutorial is outdated, please visit the CKEditor helper homepage to read the up-to-date tutorial.
Changelog
* 2010-08-28: Ronan’s patch for custom toolbar definition added (thanks dude!).
* 2010-08-28: Configuration options are now only applied on the associated CKEditor.
* 2010-08-28: Several editors can now be displayed on the same page.
* 2010-01-12: All the stuff moved out of system/plugins.
* 2010-01-30: Fixed Internet Explorer compatibility issue.
Please download first the last release of my CKEditor Helper for CodeIgniter.
This helper can, for the moment, manage all CKEditor’s available configuration options and custom styles definitions.
The first step is to download the CKEditor editor package, note that the helper have only be tested over CKEditor 3.0.2.
Place the entire ckeditor folder into the CodeIgniter’s /js/ folder (this path can be customized).
Download and place the ckeditor_helper.php file into the CodeIgniter’s system/application/helpers folder.
<?php
class Ckeditor extends Controller {
public $data = array();
public function __construct() {
parent::Controller();
$this->load->helper('url'); //You should autoload this one ;)
$this->load->helper('ckeditor');
//Ckeditor's configuration
$this->data['ckeditor'] = array(
//ID of the textarea that will be replaced
'id' => 'content',
'path' => 'js/ckeditor',
//Optionnal values
'config' => array(
'toolbar' => "Full", //Using the Full toolbar
'width' => "550px", //Setting a custom width
'height' => '100px', //Setting a custom height
),
//Replacing styles from the "Styles tool"
'styles' => array(
//Creating a new style named "style 1"
'style 1' => array (
'name' => 'Blue Title',
'element' => 'h2',
'styles' => array(
'color' => 'Blue',
'font-weight' => 'bold'
)
),
//Creating a new style named "style 2"
'style 2' => array (
'name' => 'Red Title',
'element' => 'h2',
'styles' => array(
'color' => 'Red',
'font-weight' => 'bold',
'text-decoration' => 'underline'
)
)
)
);
}
public function index() {
$this->load->view('ckeditor', $this->data);
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<textarea name="content" id="content" ><p>Example data</p></textarea>
<?php echo display_ckeditor($ckeditor); ?>
</body>
</html>
For more information or for feature request, please see the full tutorial.
Today March 23th, I changed my FCK to CK with awesomes features in this new version. first of all, I just teach HOW TO Install and load this plugin into CI, no more!! the optional features, I do not need.
Tested in:
- CI 1.7.4
- CKEditor 3.2, released on 25 February 2010
- Apache/2.2.12 (Win32)
- Windows Vista
- Download the package here
- Unzip into system\plugins\ it looks like this: \htdocs\example\system\plugins\ckeditor
- cp .\system\plugins\ckeditor\ckeditor_php5.php .\system\application\libraries\ckeditor.php
- load the library:
<?php
class Content extends MY_Controller {
function Content() {
parent::MY_Controller();
}
function index() {
$this->load->library('ckeditor',base_url() . 'system/plugins/ckeditor/');
$this->ckeditor->basePath = base_url(). 'system/plugins/ckeditor/';
$this->ckeditor->ToolbarSet = 'Basic';
}
- Put the editor into the view file
<?=form_open("content")?>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td><?=$this->ckeditor->editor("editor1","initial value");?></td>
</tr>
</table>
<?=form_close()?>
Thats all.. Good luck. ;)