我已经添加了一个文本区域控制在我的PHP页面,使用CKEditor的类。
现在,如果文本区加载为空,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必须在textarea中显示内容(以HTML代码的形式保存在MySQL数据库中),但是它没有这样做。
是什么导致了这个问题?
谢谢。
尝试在CKEditor演示文件夹中遵循"用代码替换"的示例:
- 从textarea中移除ckeditor类
- 修改jQueryUI dialog "open"事件,在对话框打开后触发它
$("#dialog-edit").dialog({
width: 680,
height: 620,
modal: true,
open: function (event, ui) {
CKEDITOR.replace('html');
}
});
写入ckeditor (config.js)配置文件
CKEDITOR.editorConfig = function( config ) {
/* ALLOW <?php ... ?> tags */
config.protectedSource.push(/<'?['s'S]*?'?>/g);
config.extraAllowedContent = 'style';
};