简体   繁体   English

CKeditor在浏览器中显示HTML标签

[英]CKeditor displaying HTML tags in browser

I have been searching for a possible cause of this issue but I couldn't find it. 我一直在寻找这个问题的可能原因,但找不到。

I already saw this topic here but it didn't help me. 我已经在这里看到了这个主题,但是并没有帮助我。

I am building a very simple CMS using exactly this technology , plus CKeditor. 我正在使用此技术以及CKeditor构建非常简单的CMS。 Everything works just fine until I decide to add some styling on my RTE, like for instance, Bold text. 一切工作都很好,直到我决定在RTE上添加一些样式,例如粗体文本。 When I press the Submit button, the rendered html has the [b] tags. 当我按下Submit按钮时,呈现的html具有[b]标记。

After some investigation I went to CKeditor's config file and wrote this: config.htmlEncodeOutput = false , which didn't help either. 经过一番调查后,我转到CKeditor的配置文件并编写了此代码: config.htmlEncodeOutput = false ,这也没有帮助。

What might the problem might be? 可能是什么问题? To not leave any questions about my code, I leave you the code below: 为了不对我的代码有任何疑问,我在下面留下了代码:

A PHP file with all the editable fields that the back end picks up: 一个PHP文件,其中包含后端拾取的所有可编辑字段:

$text13 = "innehall/text13.txt";
if (isset($_POST['body13'])) {
    $newData = nl2br(htmlspecialchars ($_POST['body13']));
    $handle = fopen($text13, "w");
    fwrite($handle, $newData);
    fclose($handle);
}
if (file_exists($text13)) {

    $myData13 = file_get_contents($text13);
    $myData13 = $myData13;
}

The back end file: 后端文件:

<form id="form" name="form" method="post">
        <label>Beskrivning:</label>
        <textarea class="ckeditor" name="body13" id="body13">
        <?php echo str_replace("<br />","",$myData13); ?>
        </textarea><br>
        <input id="submit" name="myBtn" type="submit" value="Uppdatera fältet" />
</form>

A php file with all the sources that the index will pick up: 一个PHP文件,其中包含索引将使用的所有来源:

$text13 = "administration/innehall/text13.txt";
if (file_exists($text13)) {

    $myData13 = file_get_contents($text13);
}

The index.php index.php

<div class="six columns">
      <p><?php echo $myData13 ?></p>
</div>

Can you post the contents of the text file you are saving to - I think you will find that the tags are being escaped but want to check that first. 您能张贴要保存到的文本文件的内容吗?-我想您会发现标签已被转义,但想先检查一下。

If the tags are being escaped when you save then you need to unescape them when you show the output not just echo. 如果在保存时对标签进行了转义,则在显示输出时不仅需要回显,还需要取消转义。

Also I guess $myData15 is meant to be $myData13??? 我也猜$ myData15应该是$ myData13 ???

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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