-
Notifications
You must be signed in to change notification settings - Fork 4
FCKeditor
The following explains how to incorporate FCKeditor using Code Igniter's 1.4x Libraries.
Place your FCKeditor files in your CI base directory (in this example I've put the files under a folder called plugins).
Copy FCKeditor's PHP connector class (/FCKeditor/fckeditor.php) to your application's libraries folder (/system/application/libraries), edit 'fckeditor.php' and add the following line to the top:
[code] if (!defined('BASEPATH')) exit('No direct script access allowed'); [/code]
Now create an initialization file that corresponds to your FCKeditor PHP connector class. In your 'application/init' folder create a file called 'init_fckeditor.php' and add the following code:
[code] <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
if ( ! class_exists('FCKeditor')) { require_once(APPPATH.'libraries/fckeditor'.EXT); }
$obj =& get_instance(); $obj->fckeditor = new FCKeditor('FCKEDITOR1'); $obj->ci_is_loaded[] = 'fckeditor'; ?> [/code]
The FCKeditor connector class should now be available in CI. Now simply load the library from your controller using:
[code] $this->load->library('fckeditor'); [/code]
And in your view file load the FCKeditor using the following:
[code] $this->fckeditor->BasePath = base_url() . '/plugins/fckeditor/'; $this->fckeditor->Value = 'This is some sample text. You are using FCKeditor.' ; $this->fckeditor->Create() ; [/code]
That's it! Hope this helps.
-Ralph Iron Eye/The Seventh Letter
[h3]Update for CI 1.5[/h3]
Since CI 1.5 works a bit different with libraries this is how you would do it in CI 1.5
- change the class and constructor to "Fckeditor" so the beginning of the code looks like this
[code] if (!defined('BASEPATH')) exit('No direct script access allowed');
class Fckeditor { var $InstanceName ; var $BasePath ; var $Width ; var $Height ; var $ToolbarSet ; var $Value ; var $Config ;
// PHP 5 Constructor (by Marcus Bointon <coolbru@users.sourceforge.net>)
function __construct( $instanceName )
{
$this->InstanceName = $instanceName ;
$this->BasePath = '/fckeditor/' ;
$this->Width = '100%' ;
$this->Height = '200' ;
$this->ToolbarSet = 'Default' ;
$this->Value = '' ;
$this->Config = array() ;
}
// PHP 4 Contructor function Fckeditor( $instanceName ) { $this->__construct( $instanceName ) ; }
[/code]
-
Change the filename from fckeditor.php to Fckeditor.php
-
Put this into your controller [code]$this->load->library('fckeditor','FCKEDITOR1');[/code]
-
Put this code inside a form element in your view [code] <?php $this->fckeditor->BasePath = 'system/plugins/FCKeditor/'; $this->fckeditor->ToolbarSet = 'Default'; echo $this->fckeditor->Create() ; ?> [/code]
This is BaseBath that worked for my setup. You can choose a "Basic" or "Default" view for a simple or more advanced toolbar. Edit the appearance and many other things in fckconfig.js
- This is how you can retreive the POST var after submitting
[code] $wysiwyg= $this->input->post('FCKEDITOR1'); [/code]
Update by shocki