简体   繁体   中英

CKEditor won't load php variable

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.

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');
    }
});

Write in config file of ckeditor (config.js)

CKEDITOR.editorConfig = function( config ) {

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM