【问题标题】:Setting Data to TinyMCE Editor将数据设置到 TinyMCE 编辑器
【发布时间】:2011-04-06 06:37:05
【问题描述】:

我使用htmlentities 将我的文本框值设置为其数据,例如:

<input type="text" value="<?php echo htmlentities('...');?>" />

我对 textarea 做了同样的事情:

<textarea><?php echo htmlentities('...');?></textarea>

在我将 textarea 转换为 TinyMCE 编辑器之前它工作正常...

当我将 textarea 转换为 TinyMCE 编辑器时,所有的东西都变得很糟糕,并在文本编辑器中显示编码的 html 代码。

那么如何在 TinyMCE 中设置编码的 html 数据呢?

【问题讨论】:

  • 好吧,我使用了 mysql_escape_string,我的数据按原样存储了所有 html 字符......就像: 太......

标签: php tinymce wysiwyg html-entities


【解决方案1】:

您不应该在编辑器中使用htmlentities()

【讨论】:

  • tinyMCE 正在呈现您的 html 内容。如果您使用 html 实体对其进行转换,它将按原样显示。例如'
  • 大声笑,我问的几乎和评论一样,但这个被接受了:)
【解决方案2】:

来自TinyMCE docs的示例:

$sContent = strip_tags(stripslashes($_POST['elm1']),$allowedTags);
...
<textarea id="elm1" name="elm1" rows="15" cols="80"><?php echo $sContent;?></textarea>

【讨论】:

    猜你喜欢
    • 2012-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多