customize CKEditor 3.x

Discussion in 'PHP' started by roice, Apr 17, 2011.

  1. #1
    Hello,
    I want to add CKEditor 3.x in my PHP website and I'm having some problem which I hope you knowledge in php will help me to fix it -

    I successfuly add the editor in my site with this dode:

        <?PHP
        echo "<form method='post' action='1.php'>";
    
        include "ckeditor/ckeditor.php";
        $CKEditor = new CKEditor();
        $CKEditor->editor("editor1", "<p>Initial value.</p>");
    
        echo "<input type='submit'>";
        echo "</form>";
    
        ?>
    PHP:
    now I want to modify the size and add path to images folder (so users will be able to upload them). for that I add this code:

        <?PHP
        echo "<form method='post' action='1.php'>";
        include "ckeditor/ckeditor.php";
        $CKEditor = new CKEditor();
        $CKEditor->editor("editor1", "<p>Initial value.</p>");
    
    	
    	$CKEditor->CKEDITOR.replace( 'editor1',
    		{
    			filebrowserBrowseUrl : '/browser/browse.php',
    			filebrowserUploadUrl : '/uploader/upload.php',
    			filebrowserWindowWidth : '640',
    			filebrowserWindowHeight : '480'
    		});	
    
    
    
        echo "<input type='submit'>";
        echo "</form>";
    
        ?>
    PHP:
    and as you probably guess - it didn't work ("Parse error: parse error in C:\Program Files\wamp\www\editor\1.php on line 9").
    why? I did it like in this example:
    http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_(Uploader)

    and also - where do I define the path/folder for images to be store/uploaded?

    Thank you all in advanced!
     
    roice, Apr 17, 2011 IP
  2. ROOFIS

    ROOFIS Well-Known Member

    Messages:
    1,234
    Likes Received:
    30
    Best Answers:
    5
    Trophy Points:
    120
    #2
    Try this:

    <?PHP
        echo "<form method='post' action='1.php'>";
        include "ckeditor/ckeditor.php";
        $CKEditor = new CKEditor();
        $CKEditor->editor("editor1", "<p>Initial value.</p>");
    
            {
        $CKEditor->CKEDITOR.replace('editor1');
            
                filebrowserBrowseUrl : '/browser/browse.php';
                filebrowserUploadUrl : '/uploader/upload.php';
                filebrowserWindowWidth : '640';
                filebrowserWindowHeight : '480';
            }
    
    
    
        echo "<input type='submit'>";
        echo "</form>";
    
        ?>	
    PHP:



    tell me what happens, :cool:
     
    ROOFIS, Apr 18, 2011 IP
  3. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,
    thanks for your reply -
    I see the editor and below it the error:
    Notice: Undefined property: CKEditor::$CKEDITOR in C:\Program Files\wamp\www\editor\1.php on line 8

    Fatal error: Call to undefined function replace() in C:\Program Files\wamp\www\editor\1.php on line 8
     
    roice, Apr 18, 2011 IP
  4. ROOFIS

    ROOFIS Well-Known Member

    Messages:
    1,234
    Likes Received:
    30
    Best Answers:
    5
    Trophy Points:
    120
    #4
    could you try to enforce the script with a defined DOCTYPE eg:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    Code (markup):

    seems to be a similar issue here too,
    As I can't see the full code I can only assume, I'd try the cksource forum support as well.
     
    ROOFIS, Apr 18, 2011 IP
  5. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I published poast there too, but here we have more forum activitly.
    I add your code at the top of my source (the one you wrote before) and I still have the error....

    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    </head>
    <body>
    <?PHP
        echo "<form method='post' action='1.php'>";
        include "ckeditor/ckeditor.php";
        $CKEditor = new CKEditor();
        $CKEditor->editor("editor1", "<p>Initial value.</p>");
    
            {
        $CKEditor->CKEDITOR.replace('editor1');
           
                filebrowserBrowseUrl : '/browser/browse.php';
                filebrowserUploadUrl : '/uploader/upload.php';
                filebrowserWindowWidth : '640';
                filebrowserWindowHeight : '480';
            }
    
    
    
        echo "<input type='submit'>";
        echo "</form>";
    
        ?>
    	
    <body>
    </html>	
    
    PHP:
     
    roice, Apr 18, 2011 IP
  6. ROOFIS

    ROOFIS Well-Known Member

    Messages:
    1,234
    Likes Received:
    30
    Best Answers:
    5
    Trophy Points:
    120
    #6
    <?PHP
    error_reporting(0); 
        echo "<form method='post' action='1.php'>";
        include "ckeditor/ckeditor.php";
        $CKEditor = new CKEditor();
        $CKEditor->editor("editor1", "<p>Initial value.</p>");
    PHP:
    just below the php tag add error_reporting(0); note* this may stop the error reporting but won't solve the under lying problem. Try out whatever new function your are adding to see if the code is effective. If injecting edited text/img to a BD there may be problems given the under lying problem, try anyway to see if all is functional.

    I've used error_reporting(0) on an old php 4 PR checker on xampp and it's functionality seems to be working.

    Last time I utilized ckeditor was about two years ago for one of my CMS modules, (I've switched to tinymce since then) so I'm not 100% up to date on their modules.
    give it a try anyway.
     
    Last edited: Apr 18, 2011
    ROOFIS, Apr 18, 2011 IP
  7. roice

    roice Peon

    Messages:
    200
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    OK
    I'll try to use your script - tinymce
    what is the php that create the editor?
    by the way - is it possible to do COPY PASTE to image with it?
     
    roice, Apr 18, 2011 IP