3

CKEditor のクラスを使用して、PHP ページに textarea コントロールを追加しました。
テキストエリアが空で読み込まれると、CKEditor が機能します。しかし、テキストエリアに PHP 変数を読み込もうとすると、ページにはエディターが正しく表示されますが、コンテンツは表示されません (エディターがブロックされているように見えます)。これが私のコードです:

<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>

テキストエリアはコンテンツ (MySQL データベースに HTML コードとして保存されたもの) をテキストエリアに表示する必要がありますが、これを行っていません。
この問題の原因は何ですか?
ありがとう。

4

2 に答える 2

5

代わりに、CKEditor デモ フォルダーの「コードで置換」の例に従ってみてください。

  1. テキストエリアから「ckeditor」クラスを削除します。
  2. jQueryUI ダイアログの "open" イベントを変更して、ダイアログが開かれたにトリガーされるようにします。

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

$("#dialog-edit").dialog({
    width: 680,
    height: 620,
    modal: true,
    open: function (event, ui) {
        CKEDITOR.replace('html');
    }
});
于 2013-05-10T19:58:50.337 に答える
1

ckeditorの設定ファイル(config.js)に書き込む

CKEDITOR.editorConfig = function( config ) {

    /* ALLOW <?php ... ?> tags */
    config.protectedSource.push(/<\?[\s\S]*?\?>/g); 
    config.extraAllowedContent = 'style';
};
于 2015-05-08T10:59:06.820 に答える