CKEditor in CodeIgniter

I want to load CKEditor into CodeIgniter, I am looking for a lot, but I can not understand their way.

I placed ckeditor in the application / plugins folder and now I want to make an editor, so I follow the controller method.

include APPPATH.'plugins/ckeditor/ckeditor.php'; $CKEditor = new CKEditor(); $CKEditor->basePath = '/'.APPPATH.'plugins/ckeditor/'; $initialValue = '<p>This is some <strong>sample text</strong>.</p>'; echo $CKEditor->editor("editor1", $initialValue); 

but he only makes simple teaxaria, with

This is some sample text .

value. where is the problem and how to solve it?
+6
source share
6 answers

I use these steps to add ckeditor to my encoding applications:

1) Download these files:

2) Copy the files you just downloaded to the Applications / libraries folder

3) Download the ckeditor assistant here: http://pastebin.com/Cd3GqYbx

4) Copy the last file to the application / helper folder as ckeditor_helper.php

5) Download the CKeditor controller here: http://pastebin.com/UD0bB9ig

6) Copy the controller to the application folder / controllers as ckeditor.php

7) Download the main ckeditor project from the official website: http://ckeditor.com/download/

8) Copy the ckeditor folder, which you just upload to your resources folder (if you want, you can also download the ckfinder project and put it in the same folder)

9) Add this js line to the view file (adjust the path):

 <script type="text/javascript" src="/asset/ckeditor/ckeditor.js"></script> <script type="text/javascript" src="/asset/ckfinder/ckfinder.js"></script> 

10) In your controller add this php code and configure the path:

 $this->load->library('ckeditor'); $this->load->library('ckfinder'); $this->ckeditor->basePath = base_url().'asset/ckeditor/'; $this->ckeditor->config['toolbar'] = array( array( 'Source', '-', 'Bold', 'Italic', 'Underline', '-','Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo','-','NumberedList','BulletedList' ) ); $this->ckeditor->config['language'] = 'it'; $this->ckeditor->config['width'] = '730px'; $this->ckeditor->config['height'] = '300px'; //Add Ckfinder to Ckeditor $this->ckfinder->SetupCKEditor($this->ckeditor,'../../asset/ckfinder/'); 

11) In your view, type the editor using:

 echo $this->ckeditor->editor("textarea name","default textarea value"); 
+25
source

Otherwise, you could do this:

  • copy the CKEditor files to a folder in the source root, for example ckeditor
  • Include CKEditor Files in a View File

      <script src="<?php echo base_url(); ?>ckeditor/ckeditor.js"></script> <link rel="stylesheet" href="<?php base_url(); ?>style/format.css"> 
  • Finally, your text box in your html document

      <textarea cols="80" id="edi" name="editor1" rows="10"> <?php echo $page_content->message1; ?> </textarea> <script> CKEDITOR.replace('edi'); </script> </body> 

This works great for me. Enjoy it!

+2
source

I found here a rather simple explanation from 2 lines: http://www.iprogrammerindia.in/how-to-integrate-ckeditor-in-codeigniter/#comment-73

Just in case, the link disappears, I insert the text here. This worked for me on 8/1/14:

Include this line in your view where you want to use ckeditor, and put your ckeditor folder in the root folder. Here I am located in js / ckeditor / in the root folder

 <script type="text/javascript" src="<?php echo base_url();?>js/ckeditor/ckeditor.js"></script> 

Next, include the bottom line in the same view,

 <?php echo form_textarea(array('name' =>'desc','id'=>'desc','class'=>"ckeditor")); ?> 
+1
source

Well, I know this question is old, but this is what I did, and it seems to me the easiest way.

  • In my root, I have a directory called "js", and inside this I have a directory called "plugins". I copied the ckeditor files there.
  • Then in the application/views/common/headers directory I have a header file called " ckeditor.php ". Inside this file is only the following code:
 <script type="text/javascript" src="php echo base_url();?> js/plugin/ckeditor/ckeditor.js"></script> 
  1. Then in the controller I added a header file to the object $ data, to navigate to the view: $data['header_files'] = array('header1','header2','header3', 'ckeditor'); // header file names were changed for the sake of my client $data['header_files'] = array('header1','header2','header3', 'ckeditor'); // header file names were changed for the sake of my client
  2. Then, of course, you pass the $ data object to the view: $this->load->view('common/admin-template',$data);
  3. then I just called CKEDITOR.replace ('textareaNameHere');

and voila. it works

0
source

same problem: I'm fessing, but only a small thing, and you need the whole file in the resource folder in the root folder. my controller part

 $this->load->library('ckeditor'); $this->load->library('ckfinder'); $this->ckeditor->basePath = base_url().'assets/admin/ckeditor/'; $this->ckeditor->config['toolbar'] = array( array( 'Source', '-', 'Bold', 'Italic', 'Underline', '-','Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo','-','NumberedList','BulletedList' ) ); $this->ckeditor->config['language'] = 'en'; $this->ckeditor->config['width'] = '730px'; $this->ckeditor->config['height'] = '300px'; //Add Ckfinder to Ckeditor $this->ckfinder->SetupCKEditor($this->ckeditor,base_url().'asset/admin/ckfinder/'); 


My view part

 <div class="form-group"> <label for="description">Description</label> <?php echo form_error('event_description'); ?> <?php echo $this->ckeditor->editor("event_description",((isset($event_description)) ? $event_description : ''));?> </div> 

I put the edk ck folder in the assets folder and the resources folder in the root file as
C: \ WAMP \ WWW \ site \ assets \ admin \ CKEditor

0
source
  1. Download the CKEditor package from https://ckeditor.com/ckeditor-4/download/
  2. Unzip the folder in the Codeigniter project folder in your preferred location.
  3. Include the <script> element loading CKEditor into your page.
  4. Use the CKEDITOR.replace() method to replace the existing <textarea> element with CKEditor.

See the following example:

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>A Simple Page with CKEditor</title> <!-- Make sure the path to CKEditor is correct. --> <script src="../ckeditor.js"></script> </head> <body> <form> <textarea name="editor1" id="editor1" rows="10" cols="80"> This is my textarea to be replaced with CKEditor. </textarea> <script> // Replace the <textarea id="editor1"> with a CKEditor // instance, using default configuration. CKEDITOR.replace( 'editor1' ); </script> </form> </body> </html> 
0
source

Source: https://habr.com/ru/post/922147/


All Articles