ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

CKeditor and CI implementation

August 26, 2009 8:58am

Subscribe [16]
  • #1 / Aug 26, 2009 8:58am

    MaartenDeGroote

    16 posts

    Dear CI-community,

    Since a few weeks the follow-up of FCKeditor, called CKeditor, has been released. Does anyone already have any experience on installing this one in CI? I’m kinda struggling with it here since I’m fairly new to php frameworks…

    Thanx!

    Martin

  • #2 / Sep 04, 2009 1:50pm

    spmckee

    56 posts

    I would love to knw this too. I have FCKeditor up and running but would love to replace it.

  • #3 / Sep 04, 2009 2:53pm

    Josepzin

    28 posts

    There are not PHP option in CKEditor, but i am making a helper for me:

    *** delete the space of the script tag after the “<” ***

    ckeditor_helper.php

    <?php
    if(!defined('BASEPATH')) exit('No direct script access allowed');
    
    function form_ckeditor($data)
    {
        $data['language'] = isset($data['language']) ? $data['language'] : 'es';
        
        $size    = isset($data['width']) ? 'width: "'.$data['width'].'", ' : '';
        $size  .= isset($data['height']) ? 'height: "'.$data['height'].'", ' : '';
        
        $options = '{'.
                $size.
                'language: "'.$data['language'].'", 
                
                stylesCombo_stylesSet: "my_styles",
                
                startupOutlineBlocks: true,
                entities: false,
                entities_latin: false,
                entities_greek: false,
                forcePasteAsPlainText: false,
                
                filebrowserImageUploadUrl : "filexplorers/fckeditor_upload/image", // << My own file uploader
                filebrowserImageBrowseUrl : "filexplorers/inlinebrowse/image", // << My own file browser
                filebrowserImageWindowWidth : "80%",
                filebrowserImageWindowHeight : "80%",   
    
                
                toolbar :[
                    ["Source","-","FitWindow","ShowBlocks","-","Preview"],
                    ["Undo","Redo","-","Find","Replace","-","SelectAll","RemoveFormat"],
                    ["Cut","Copy","Paste","PasteText","PasteWord","-","Print","SpellCheck"],
                    ["Form","Checkbox","Radio","TextField","Textarea","Select","Button","ImageButton","HiddenField"],
                    ["About"],
                        
                    "/",
                    
                    ["Bold","Italic","Underline"],
                    ["OrderedList","UnorderedList","-","Blockquote","CreateDiv"],
                    
                    ["Image","Flash","Table"],
                    
                    ["Link","Unlink","Anchor"],
                    ["Rule","SpecialChar"],
                    ["Styles"]
                ]
            }';
        
        
        $my_styles = 'CKEDITOR.addStylesSet("my_styles",
            [
                // Block Styles
                { name : "H3", element : "h3"},
                { name : "Heading 4", element : "h4"},
                { name : "Heading 5", element : "h5"},
                { name : "Heading 6", element : "h6"},
                { name : "Document Block", element : "div"},
                { name : "Preformatted Text", element : "pre"},
                { name : "Address", element : "address"},
            
                // Inline Styles
                { name: "Centered paragraph", element: "p", attributes: { "class": "center" } },
                
                { name: "IMG bordered", element: "img", attributes: { "class": "bordered" } },
                
                { name: "IMG left", element: "img", attributes: { "class": "left" } },
                { name: "IMG right", element: "img", attributes: { "class": "right" } },
                
                { name: "IMG left bordered", element: "img", attributes: { "class": "left bordered" } },
                { name: "IMGright bordered", element: "img", attributes: { "class": "right bordered" } },
            ]);';
        
        
        
    
        return 
        // fix: move to <HEAD…
        '< script type="text/javascript" src="'.base_url().'application/plugins/ckeditor/ckeditor.js"></ script>' .
    
        // put the CKEditor
         '< script type="text/javascript">' .
                $my_styles .
                'CKEDITOR.replace("'.$data['id'].'", ' . $options . ');</ script>';
    }


    To use:

    echo form_ckeditor(array(
                'id'              => 'textarea_id',
                'width'           => '500',
                'height'          => '300',
                'value'         => htmlentities($textarea_value)
            ));

    There is not finished, it works but i dont know if is the best way to do it.

  • #4 / Sep 04, 2009 3:07pm

    Josepzin

    28 posts

    Humm… here a minimized version 😛

    ckeditor_helper.php

    <?php
    if(!defined('BASEPATH')) exit('No direct script access allowed');
    
    function form_ckeditor($data)
    {
        return '< script type="text/javascript" src="'.base_url().'application/plugins/ckeditor/ckeditor.js"></ script>' .
         '< script type="text/javascript">CKEDITOR.replace("'.$data['id'].'");</ script>';
    }


    To use:

    echo form_ckeditor(array('id'=>'textarea_id'));
  • #5 / Sep 05, 2009 7:23am

    MaartenDeGroote

    16 posts

    Wow that’s great. Thanks for your contributions. I’m about to try them out soon..

    Regards,

    Martin

  • #6 / Sep 05, 2009 6:04pm

    Piter

    31 posts

    Hello, I have problem:

    Błąd: uncaught exception: [CKEDITOR.editor.replace] The element with id or name “text” was not found.

    Unfortunately I can not resolve it. With JavaScript on me heavily.

  • #7 / Sep 14, 2009 6:53pm

    goran_zg

    5 posts

    Sorry, I don’t get this uploader and browser file, is there some example or smth.

    thnx in advance

  • #8 / Nov 08, 2009 4:44am

    basty_dread

    107 posts

    how could i fix this.. it says:

    Fatal error: Call to undefined function form_ckeditor() in /home/myproject/public_html/system/application/views/step5view.php on line 175

    i follow the steps above..
    please help.. i want to integrate this new version of CKeditor. thanks

  • #9 / Nov 08, 2009 6:51pm

    Johan André

    412 posts

    how could i fix this.. it says:

    Fatal error: Call to undefined function form_ckeditor() in /home/myproject/public_html/system/application/views/step5view.php on line 175

    i follow the steps above..
    please help.. i want to integrate this new version of CKeditor. thanks

    Well… did you load the helper?

  • #10 / Nov 08, 2009 9:31pm

    basty_dread

    107 posts

    i fix my integration using the new ckeditor version 3.0.1. 

    by using this code::::

    <s+c+r+i+p+t+ type="text/javascript" src="../../javascript/ckeditor/ckeditor.js"></s+c+r+i+p+t+> // include this on head tag… edit it for the path of your ckeditor.
    
    <textarea name="nf_editor"><p>Initial value.</p></textarea>
                           <s+c+r+i+p+t type="text/javascript">
                                 CKEDITOR.replace( 'nf_editor' );
                        </s+c+r+i+p+t>

    and thats it… no more configs.
    (remove the + sign on the script.. because the forum put [remove] [remove] on javascripts)

  • #11 / Feb 15, 2010 11:04pm

    dezafu

    6 posts

    first copy CKEditor folder to your web root
    simply just add javascript for CKEditor

    //For PHP
    <?=script('ckeditor/ckeditor.js');?>
    <?=script('ckeditor/adapters/jquery.js');?>
    
    //For Javasctipt
    $(function()
    {
        var configFull = {
            toolbar:
            [
                ['Source','-','Save','NewPage','Preview','-','Templates'],
                ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
                ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
                ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
                '/',
                ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
                ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
                ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
                ['Link','Unlink','Anchor'],
                ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
                '/',
                ['Styles','Format','Font','FontSize'],
                ['TextColor','BGColor'],
                ['Maximize', 'ShowBlocks','-','About']
            ],
            filebrowserBrowseUrl : '<?=base_url()?>index.php/ajax/browse',
            filebrowserUploadUrl : '<?=base_url()?>index.php/ajax/upload',
            filebrowserImageBrowseUrl : '<?=base_url()?>index.php/ajax/imageBrowse',
            filebrowserFlashBrowseUrl : '<?=base_url()?>index.php/ajax/flashBrowse',
            filebrowserImageUploadUrl : '<?=base_url()?>index.php/ajax/imageUpload',
            filebrowserFlashUploadUrl : '<?=base_url()?>index.php/ajax/flashUpload',
    
            
        };
        
        var configBasic = {
            toolbar:
            [
                ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink']
            ]
        }
    
        // Initialize the editor.
        // Callback function can be passed and executed after full instance creation.
        $('body')
            .find('textarea.ckfull')
                .ckeditor(configFull)
            .end()
            .find('textarea.ckbasic')
                .ckeditor(configBasic);
    });
  • #12 / Feb 23, 2010 6:32am

    basty_dread

    107 posts

    Hi there i need a simple image upload/ flash upload sample

    because i dont know how it could get uploaded

    just simple upload for the image and flash

    using ckeditor.

    Thanks

  • #13 / Mar 23, 2010 5:29pm

    Nicolas Rios

    1 posts

    check the Wiki:
    http://codeigniter.com/wiki/CKEditor/

    I put how to install and config with FCK 3.2 .

    Regards,

  • #14 / Mar 26, 2010 5:55pm

    DTR_

    1 posts

    check the Wiki:
    http://codeigniter.com/wiki/CKEditor/

    I put how to install and config with FCK 3.2 .

    Regards,

    Can you also show how to integrate ckfinder in it?
    Thanks.

  • #15 / May 03, 2010 11:41am

    Carlos Alcala

    7 posts

    The post is very nice and works like a charm, BUT can you also explain how to set up the CKFinder integration with CKEditor?

    Thanks,

    Carlos

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases