2013-05-10 59 views
3

我已經使用CKEditor的類在我的PHP頁面中添加了一個textarea控件。
現在,如果textarea加載空,CKEditor的作品。但是,如果我嘗試在textarea中加載一個PHP變量,頁面將正確顯示編輯器,但它不會顯示內容(並且編輯器似乎被阻止)。 這裏是我的代碼: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> 

textarea的必須顯示內容(保存在MySQL數據庫作爲HTML代碼),到textarea的,但它沒有這樣做。
這是什麼問題?
謝謝。

+0

您是否嘗試'回聲$ HTML;',而不是'$打印HTML;'?你確定'$ html'的價值嗎? – 2013-05-10 14:40:34

+0

@ Siamak.A.M是的,它仍然沒有工作... – 2013-05-10 14:41:56

+0

我很確定'$ html'的值是空的。你可以在其他地方迴應它,看看它是否爲空? – 2013-05-10 14:45:23

回答

5

嘗試下面的例子中CKEditor的demo文件夾,而不是「由代碼替換」:

  1. 從文本區域中刪除「CKEditor的」類。
  2. 修改jQueryUI對話框「打開」事件觸發它對話框打開。

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

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

寫的CKEditor的配置文件(config.js)

CKEDITOR.editorConfig = function(config) { 

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