3
votes

i've added a textarea control in my PHP page, using the CKEditor's class.
Now if the textarea loads empty, CKEditor works. But if i try to load a PHP variable in the textarea, the page show correctly the editor, but it won't show the content (and the editor appears to be blocked). Here's my code:

<div id="dialog-edit" title="Edit" style="display: none;">
    <table cellspacing="10">
        <tr>
            <td>
                <table>
                <form method="post" name="form">
                <tr>
                        <td>

                </td>
                <td>

                </td>
                <td>

                </td>
                </tr>
                </table>                    
                <br/>
                <textarea class="ckeditor" name="html" id="html" style="width: 766px; height: 390px; margin-left: 6px;"><?php echo htmlentities($html) ?></textarea><br/>
                <input type="submit" name="save" id="save" value="Salva modifiche" class="button" />
                </form>
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">
    function showDialogEdit()
    {
        $( "#dialog-edit" ).dialog({

                width: 680,
                height: 620,
                modal: true,
                open: function(event, ui)
                {

                }
            });
    }
</script>

The textarea must show the content (saved in a MySQL database as an HTML code), into the textarea, but it isn't doing this.
What's making this issue?
Thanks.

2
Have you tried echo $html; instead of print $html; ? And are you sure about the value of $html ? - Siamak A.Motlagh
@Siamak.A.M yes, and it isn't still working... - Francis
Without a more complete sample of your code, it's impossible to say. Please post more code and/or create a functional example at jsfiddle.net - Blazemonger
jsfiddle.net/mblase75/g2HFn/3 -- still no problems. However, let me know if following this example works -- it uses the jQueryUI Dialog "open" event to trigger CKEditor without the "ckeditor" class. - Blazemonger
@FrancescoSorge If Blazemonger's answer solved the problem, please accept the answer. It gives credit for the effort and tells people who are searching about a similar problem that a helpful answer was given for your question. - codewaggle

2 Answers

5
votes

Try following the "replace by code" example in the CKEditor demo folder instead:

  1. Remove the "ckeditor" class from the textarea.
  2. Modify the the jQueryUI dialog "open" event to trigger it after the dialog is opened.

http://jsfiddle.net/mblase75/g2HFn/4/

$("#dialog-edit").dialog({
    width: 680,
    height: 620,
    modal: true,
    open: function (event, ui) {
        CKEDITOR.replace('html');
    }
});
1
votes

Write in config file of ckeditor (config.js)

CKEDITOR.editorConfig = function( config ) {

    /* ALLOW <?php ... ?> tags */
    config.protectedSource.push(/<\?[\s\S]*?\?>/g); 
    config.extraAllowedContent = 'style';
};