CodeIgniter Forums
Fckeditor in CodeIgniter 1.7.1 in 10 steps - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Fckeditor in CodeIgniter 1.7.1 in 10 steps (/showthread.php?tid=16366)

Pages: 1 2


Fckeditor in CodeIgniter 1.7.1 in 10 steps - El Forum - 03-04-2009

[eluser]jongliko[/eluser]
I just figure out how to use Fckeditor as a Library in CI.

It's indeed simple but in the wiki ( http://codeigniter.com/wiki/FCKeditor/ ) it's hard to understand witch updates to do for the last CI version (1.7.1). I have seen in the forum that others have problems to understand, so I post a little step by step.

1)Download Fckeditor.
2)Extract the folder "fckeditor" in "system/plugins/"
3)Open the "fckeditor" folder and copy the file "fckeditor.php"
4)Past the file in "system/application/libraries"
5)Edit the file you just past and add this line to the top
Code:
if (!defined('BASEPATH')) exit('No direct script access allowed');
6)In the same file now change the path of the include to have something like
Code:
if ( !function_exists('version_compare') || version_compare( phpversion(), '5', '<' ) )
    include_once( 'system/plugins/fckeditor/fckeditor_php4.php' ) ;
else
    include_once( 'system/plugins/fckeditor/fckeditor_php5.php' ) ;
7)Open the file "system/plugins/fckeditor/fckeditor_php5.php" and add this line to the top
Code:
if (!defined('BASEPATH')) exit('No direct script access allowed');
8)Change this part of the class
Code:
class FCKeditor
{

    public $InstanceName ;
    public $BasePath ;
    public $Width ;
    public $Height ;
    public $ToolbarSet ;
    public $Value ;
    public $Config ;


    public function __construct( $instanceName )
     {
        $this->InstanceName    = $instanceName ;
        $this->BasePath        = '/fckeditor/' ;
        $this->Width        = '100%' ;
        $this->Height        = '200' ;
        $this->ToolbarSet    = 'Default' ;
        $this->Value        = '' ;

        $this->Config        = array() ;
    }
    
...
into this

Code:
class Fckeditor
{

    var $InstanceName ;
    var $BasePath ;
    var $Width ;
    var $Height ;
    var $ToolbarSet ;
    var $Value ;
    var $Config ;


    public function __construct( $array )
     {
        $this->InstanceName = $array['instanceName'] ;
        $this->BasePath        = $array['BasePath'] ;
        $this->Width        = $array['Width'] ;
        $this->Height        = $array['Height'] ;
        $this->ToolbarSet    = $array['ToolbarSet'] ;
        $this->Value        = $array['Value'] ;

        $this->Config        = array() ;
    }
    
...

8-bis) open the fckeditor_php4.php and add the same line to the top and rename the class name into "class Fckeditor"

9)In your controller you should have something like
Code:
function fckeditorform(){
    
   $fckeditorConfig = array(
          'instanceName' => 'content',
          'BasePath' => base_url().'system/plugins/fckeditor/',
          'ToolbarSet' => 'Basic',
          'Width' => '100%',
          'Height' => '200',
          'Value' => ''
            );
   $this->load->library('fckeditor', $fckeditorConfig);
   $this->load->view('fckeditorView');
        
}
function fckeditorshowpost(){
    
        echo $this->input->post('content');
        
}
10)In your view you should have something like
Code:
$this->load->helper('form');
echo '<h1>FckEditor</h1>';
echo form_open('yourcontroller/fckeditorshowpost');

echo $this->fckeditor->Create() ;

echo form_submit(array('value'=>'submit'));
echo form_close();



Any problem use the wiki http://codeigniter.com/wiki/FCKeditor/ to complete my post

Hope this help ! ;-)


Fckeditor in CodeIgniter 1.7.1 in 10 steps - El Forum - 03-04-2009

[eluser]jdfwarrior[/eluser]
I have a feeling you will be receiving much praise for this.


Fckeditor in CodeIgniter 1.7.1 in 10 steps - El Forum - 03-04-2009

[eluser]TheFuzzy0ne[/eluser]
Assuming it works; good job! However, this would probably be best posted in the Ignited Code forum. Just out of interest, what was wrong with the guide on the wiki?


Fckeditor in CodeIgniter 1.7.1 in 10 steps - El Forum - 03-04-2009

[eluser]jongliko[/eluser]
Nothing really wrong with the Wiki, but it took me 4 hours to make everything works.... :-S

With this post I would have past 10 minutes ;-)


Fckeditor in CodeIgniter 1.7.1 in 10 steps - El Forum - 03-05-2009

[eluser]umefarooq[/eluser]
really nice 10 steps and its working fine, have you try to put image with fckeditor in content, right now im facing this problem when i try to browse image,flash or files directory it gives me the following javascript popup

Code:
The server didn't reply with a proper XML data. Please check your configuration.

im facing same sort of problem with tinymce also.


Fckeditor in CodeIgniter 1.7.1 in 10 steps - El Forum - 03-05-2009

[eluser]jongliko[/eluser]
No, I'm not using the upload/browse files functions for my current project. But it could be great to complete those steps with the upload/browse configuration for CI.


Fckeditor in CodeIgniter 1.7.1 in 10 steps - El Forum - 03-05-2009

[eluser]umefarooq[/eluser]
i just check the in CI doc there is written that

Code:
GET data is simply disallowed by CodeIgniter

here you can check in doc

Get data

how to enable enable GET for any editors only like fckeditor or tinymce. for ajax purpose these editors are passing variables using get to php files.


Fckeditor in CodeIgniter 1.7.1 in 10 steps - El Forum - 03-21-2009

[eluser]Unknown[/eluser]
I went thru this guide and also used the wiki guide (http://codeigniter.com/wiki/FCKeditor/) and found that it works great for php5, but there are issues with php4.

We are in the process of upgrading our sites to php5, but until then I followed the steps as they were written in this thread, but changed to calls to the fckeditor in the controller as follows:

$fckeditorConfig = array(
'instanceName' => 'txtHtml',
'ToolbarSet' => 'Basic',
'Width' => '100%',
'Height' => '200',
'Value' => $somevalue
);

if ( !function_exists('version_compare') || version_compare(phpversion(), '5', '<' ) )
{
// php4
$this->load->library('fckeditor',$fckeditorConfig);

$this->fckeditor->InstanceName = 'txtHtml';
$this->fckeditor->BasePath = base_url().'system/plugins/fckeditor/';
$this->fckeditor->Width = '100%';
$this->fckeditor->Height = '200';
$this->fckeditor->ToolbarSet = 'Default';
$this->fckeditor->Value = $somevalue;

} else {

$this->load->library('fckeditor', $fckeditorConfig);
}

In php4, it doesn't matter what you use for the second parameter in the load->library('fckeditor',$fckeditorConfig). I had to override them directly after the load and all worked fine.


Fckeditor in CodeIgniter 1.7.1 in 10 steps - El Forum - 04-01-2009

[eluser]MeDHaT[/eluser]
If you want to use a template parser, make sure to use

$this->fckeditor->CreateHtml() ;

instead of $this->fckeditor->Create() ;

to store the editor in a variable for a later rendering, otherwise the editor will appear at the top of the page whatever you do..

I was not aware of that and spent my whole day trying to put the editor inside the form Smile


Fckeditor in CodeIgniter 1.7.1 in 10 steps - El Forum - 06-16-2009

[eluser]hellomoto[/eluser]
thanks ..very helpfull