thinkphp3.2 embedded Baidu editor ueditor method example
This article mainly introduces the example code of thinkphp3.2 embedded in Baidu editor ueditor. It has certain reference value. Those who are interested can learn about it. I hope it can help everyone.
This article introduces thinkphp3.2 to embed Baidu editor ueditor, share it with everyone, I hope this article will be helpful to you
Due to typesetting requirements, many times we need Embed a rich text editor and output text content with html tags. Because I recently worked on a backend management system that requires editing the text content so that it can output text with html tags and save it to the server. The client sends a request to get the tagged text from the server. I use ueditor,
put it in the Public directory.
2. When we use the rich text editor on the view, we usually add textarea to the form,
<form> <p><textarea name="intro_detail" id="intro_detail" cols="30" rows="10"></textarea> </p> </form>
3. Add the initial value of the script configuration text box at the end of the html, where PUBLIC is the path I configured in config
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script> <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.min.js"></script> <!--建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败--> <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文--> <script type="text/javascript" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script> <script type="text/javascript"> UE.getEditor('intro_detail',{ //intro_detail为要编辑的textarea的id initialFrameWidth: 418, //初始化宽度 initialFrameHeight: 500, //初始化高度 }); </script>
4. Usually we When adding a button to the form, all the data in the form will be submitted by default. However, my project also involves image uploading. I use ajax asynchronous submission here. So the question is, can we pass it? The value of ("#intro_detail").val() in jq gets the value to be submitted. The answer is no. My solution is to add a hidden input under the textarea. We use the method provided by ueditor. Get the value inside and assign it to the input, and let it be submitted along with the form. In the controller, you can pass _POST('name of the form'), as follows:
<p > <textarea name="intro_detail" id="intro_detail" cols="30" rows="10"></textarea> </p> <input type="text" style="display: none" id="intro_detail1" name="intro_detail1" >
ajax submission,
Copy code The code is as follows:
$("#intro_detail1").val("'"+UE.getEditor(' intro_detail').getContent()+"'");
Use single quotes to put the labeled input in the text box together, save it in the input and send it over at the same time. As for why you use single quotes, otherwise If it cannot be sent, the tags will be automatically filtered out. We just need to remove the single quotes when getting the data.
$.ajax({ type: "POST", url: "<{:U('Admin/GameManager/Game/modGame')}>", dataType: 'json', processData: false, contentType: false, cache: false, data: formData, success:function(r){ if(r.success){ alert('编辑成功'); window.location.reload();//重新刷新一次 $('#user_dialog').modal('hide'); } else{ alert("参数错误"); } } });
5. In the controller, you can use $_POST('name of the form') to get the data and write it into the database
$db = M('game'); $data = $db->create(I('post.')); $data['intro_detail'] = $_POST['intro_detail1']; $db->add($data);
6. When we get the data to the view, we can just remove the single quotes
foreach($result as $key =>$value){ $result[$key]['intro_detail']=str_replace("'","",$result[$key]['intro_detail']);//过滤单引号 } $this->assign('game_list', $result); $this->display('');
$result is what I found using the sql statement Database content, and intro_detail is the text content with labels and single quotes stored in the database
$user = M('game'); $result = $user->field();
7. In fact, it is not difficult. I am also providing you with ideas. You can add more Discussion, I am also a novice.
Related recommendations:
How to embed tp3 into Baidu editor ueditor?
The above is the detailed content of thinkphp3.2 embedded Baidu editor ueditor method example. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Have you ever faced any issues while transferring files that prevented you from doing so? Well, many Windows users have recently reported that they faced issues while copying and pasting files into a folder, where an error was thrown saying “The file name of the destination folder is too long”. Additionally, some other Windows users expressed frustration when opening any file and said "the file name or extension is too long" and they were unable to open the file. This disappoints users by not allowing them to transfer files to any other folder. While analyzing the issue, we have come up with a series of solutions that may help alleviate the issue and allow users to transfer files easily. If you are in a similar situation, please see this post for more information. Source: https

Many Windows users have recently reported that they were annoyed when Windows Defender SmartScreen warned users not to launch applications that were not recognized by Microsoft Windows and they had to click on the "Run anyway" option every time. Windows users are unsure what they can currently do to avoid or disable it. After researching the issue, we found that Windows Defender functionality on the system can be disabled through the Settings application or the Local Group Policy Editor or by adjusting the registry files. By doing this, users will no longer have to face the defender SmartScreen. If your system also encounters

There is no better way to write Python code than using an integrated development environment (IDE). Not only can they make your work simpler and more logical, they can also improve programming experience and efficiency. Everyone knows this. The question is, how to choose the best Python development environment among the many options.

C language is a basic and important programming language. For beginners, it is very important to choose appropriate programming software. There are many different C programming software options on the market, but for beginners, it can be a bit confusing to choose which one is right for you. This article will recommend five C language programming software to beginners to help them get started quickly and improve their programming skills. Dev-C++Dev-C++ is a free and open source integrated development environment (IDE), especially suitable for beginners. It is simple and easy to use, integrating editor,

Many Windows users have encountered the problem of being unable to log in to Windows 11/10 systems due to failed login attempts or multiple system shutdowns. Users are frustrated because there is nothing they can do about it. Users may forget their PIN code to log into the system, or experience lags when using or installing software, and the system may be forced to shut down multiple times. Therefore, we have compiled a list of the best available solutions that will undoubtedly help consumers solve this problem. To learn more, continue reading this article. Note: Before doing this, make sure you have your system's administrator credentials and Microsoft account password to reset your PIN. If not, wait an hour or so and try with the correct PIN

Title: Introduction to Go language development tools: List of essential tools In the development process of Go language, using appropriate development tools can improve development efficiency and code quality. This article will introduce several essential tools commonly used in Go language development, and attach specific code examples to allow readers to understand their usage and functions more intuitively. 1.VisualStudioCodeVisualStudioCode is a lightweight and powerful cross-platform development tool with rich plug-ins and functions.

Remember Windows MovieMaker on Windows 7? Since discontinuing Windows MovieMaker, Microsoft hasn't launched any real movie makers. On the other hand, they tried to revamp the Photos app with a small and lightweight built-in video editor. After a long time, Microsoft launched Clipchamp, a better video processor for all Windows 11 devices. In this article, we’ll take a deep dive into how to get everything from the Clipchamp app on your Windows 11 device. How to use Clipchamp – Detailed tutorials are available

Python is a very easy to learn, powerful programming language. Python includes efficient high-level data structures, providing simple and efficient object-oriented programming. The learning process of Python is indispensable without an IDE or code editor, or an integrated development editor (IDE). These Python development tools help developers speed up development using Python and improve efficiency. An efficient code editor or IDE should provide plug-ins, tools and other features that can help developers develop efficiently. 1.VimVim can be said to be the best IDE for Python. Vim is an advanced text editor designed to provide the actual Unix editor 'Vi' functionality and support more and more complete features.
