[英]I'm using trumbowyg as text editor for the textareas in my forum, but how do I echo it?
I didn't find any post related to my problem, so here I go:我没有找到任何与我的问题相关的帖子,所以我在这里 go:
I added trumbowyg (it's a WYSIWYG editor) to edit the content in my <textarea></textarea>
, and it works just fine when I post it in my database.我添加了trumbowyg (它是一个所见即所得的编辑器)来编辑我的
<textarea></textarea>
中的内容,当我将它发布到我的数据库中时它工作得很好。
Only problem is: how do I echo it?唯一的问题是:我如何回应它?
The parsing method of trumbowyg takes this form: you click on, let's say B in the toolbar on top of the textarea, and it will put your text in bold weight. trumbowyg的解析方法采用这种形式:您单击文本区域顶部工具栏中的B ,它会将您的文本加粗。 But in the server, once posted, it takes actually this form:
<strong>some text</strong>
.但是在服务器中,一旦发布,它实际上采用这种形式:
<strong>some text</strong>
。
Obviously, when I echo the var stocking the data in this part of my sql request, it output it the same way: <strong>some text</strong>
and not some text .显然,当我在我的 sql 请求的这一部分回显存储数据的 var 时,它 output 以相同的方式:
<strong>some text</strong>
and not some text 。
I don't know if it's actually so simple that I can't seem to find the solution, or if I'm trying something impossible... ?我不知道它是否真的如此简单以至于我似乎无法找到解决方案,或者我是否正在尝试不可能的事情......?
Thanks by advance guys !感谢提前的家伙!
Well... Guess it was so obvious that I didn't find the answer in here.好吧……我猜它太明显了,我没有在这里找到答案。 If it can help people who find themselves in the same situation as me: just wrap your var containing html with
html_entity_decode($var)
That's it.如果它可以帮助发现自己处于与我相同情况的人:只需将包含 html 的 var 包装为 html_entity_decode
html_entity_decode($var)
即可。
See below (textarea is showed if the user consulting the profile is the one wich it belongs to, else it just echo the descrption (called in an Action.php file, I didn't put the "requires" before the <!DOCTYPE html>
declaration.见下文(如果用户咨询配置文件是它所属的那个,则显示文本区域,否则它只是回显描述(在 Action.php 文件中调用,我没有在
<!DOCTYPE html>
之前放置“requires” <!DOCTYPE html>
声明。
<!DOCTYPE html>
<html lang="en">
<?php include "includes/head.php"; ?>
<body>
<?php include ("includes/navbar.php") ?>
<div class="container">
<h2><?= $user_pseudo;?></h2>
<h5><?= $user_access_level;?></h5>
<?php
if($_SESSION['id'] == $user_id){
?>
<form method="POST">
<textarea id="parse" name="description"><?= $user_description; ?></textarea>
<button class="btn btn-primary" name="validate" type="submit">Mettre à jour</button>
</form>
<?php
} else {
?>
<br/><br/><br/>
<div class="container">
<?= html_entity_decode($user_description) ?>
</div>
</div>
<?php
}
?>
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-3.3.1.min.js"><\/script>')</script>
<script src="trumbowyg/dist/trumbowyg.min.js"></script>
<script>
$('#parse').trumbowyg();
</script>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.