Search code examples
phpstringckeditor

assign ckeditor to a string


 include_once 'include/ckeditor/ckeditor.php' ;
 require_once 'include/ckfinder/ckfinder.php' ;

//ckeditor code
 $ckeditor = new CKEditor() ;
 $ckeditor->basePath    = $_path['url'] . '/include/ckeditor/' ;
 CKFinder::SetupCKEditor( $ckeditor, $_path['url'] . '/include/ckfinder' ) ;
 $ckeditor->editor('reason_data', $reason_data);

There is a page which has a table and needs to load the CKeditor inside a element.The whole html is assigned to a PHP string which is created as the response of a sql query.I am unsure about how can I place the ckeditor code within the string.

$absent_leave_table = '<table width="100%" border="0" 
cellpadding="5" cellspacing="0" class="display absent_tbl">'; 
$absent_leave_table .='<tr><td>col1</td>
<td><input type="text" id="startdate1">value from database</td></tr>'...; 

In between some I need to paste ckeditor code.I am confused how to assign the ckeditor code within the string variableabsent_leave_table.


Solution

  • CKEditor is executed on clients's side. Content, which you want to edit, should be wrapped with elements (Text area or div) converted later into an editor. When you wrap such content, then you should execute proper JS method which will initialise editor in proper place. Such as: CKEDITOR.replace, CKEDITOR.inline, etc.

    I think helpful would analysing this example. Here editor is created and destroyed multiple times on website. Or this one when editor is created after doubleclick.

    Sum up, I would see it in a way where you wrap content which wish to edit, with some div or text area. Execute JS code to initialise editor in proper place.