


yii2 integrates Baidu editor umeditor, yii2 integrates umeditor_PHP tutorial
yii2 integrates Baidu editor umeditor, yii2 integrates umeditor
Author: Bailang Source: www.manks.top/article/yii2_umeditor
The copyright of this article belongs to the author, and you are welcome to reprint it. However, this statement must be retained without the author's consent, and a link to the original text must be provided in an obvious position on the article page. Otherwise, we reserve the right to pursue legal liability.
In actual work, it is inevitable that we will not encounter development work such as news and articles, which requires the operation personnel to publish them. However, some friends, in order to save trouble, divide three by five and divide by two. ok, online. The girl who runs it tried it out, and oh my, the content of your article gave me a big trouble textarea
That’s it, it’s over. You can’t beat me to death by publishing a news article. Next, let’s talk about how the Yii2
framework integrates Baidu Editor umeditor
.
What is umeditor
? I have only heard of ueditor
. Is your umeditor
a pirated version of Dongdongnan? umeditor
, to put it bluntly, is the mini version of ueditor
. According to Baidu official statement, it is actually the "short, soft and small" version of the editor, but has all the functions. Ahem, let’s get back to the topic.
First of all, let’s go to the official website to download a mini version of ueditor umeditor
. Note that it is um editor
.
, unzip it and put it in the /css
directory under the project root directory and name it umeditor
. You can choose the exact location as long as you can reference it later.
The second step is to extend the backendassetsAppset
class first. Oh my god, why do we need to extend such a thing? What does it have to do with our umeditor
integration? Cheng Yaojin came out halfway. The purpose of extending this class file here is to facilitate the introduction of css
js
files into the file later.
It’s very simple, just add the following two methods to the Appset
method
//定义按需加载JS方法,注意加载顺序在最后 public static function addScript($view, $jsfile) { $view->registerJsFile($jsfile, [AppAsset::className(), 'depends' => 'backend\assets\AppAsset']); } //定义按需加载css方法,注意加载顺序在最后 public static function addCss($view, $cssfile) { $view->registerCssFile($cssfile, [AppAsset::className(), 'depends' => 'backend\assets\AppAsset']); }
Next, follow the configuration below.
Let me explain first. Here we assume that there is an article article
table and a content content
field that needs to be displayed in Baidu Editor.
According to the form model of yii2
, we modify the article_form.php
fieldcontent
in the
<?= $form->field($model, 'content')->textarea(['style' => 'width:760px;height:500px;']) ?>
This file introduces the Appset
class and the related css<code> <code>js
files as follows
use backend\assets\AppAsset; AppAsset::register($this); AppAsset::addCss($this,'/css/umeditor/themes/default/css/umeditor.css'); AppAsset::addScript($this,'/css/umeditor/umeditor.config.js'); AppAsset::addScript($this,'/css/umeditor/umeditor.min.js'); AppAsset::addScript($this,'/css/umeditor/lang/zh-cn/zh-cn.js');
Then you only need to register the following js<code>js
code at the bottom of the current page to achieve
<?php $this->beginBlock('js-block') ?> $(function () { var um = UM.getEditor('article-content', { }); }); <?php $this->endBlock() ?> <?php $this->registerJs($this->blocks['js-block'], \yii\web\View::POS_END); ?>
About how to use article-content<code>article-content
, this is the target object we want to bind, that is, content<code>. <code>article-content<code>content<code>。<code>article-content
is the current id<code>id
identification of the object.
ok, now the Baidu editor is basically integrated. Now hurry up and add an article to give it a try. Remember to update to see if there is content in the editor

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

AI Hentai Generator
Generate AI Hentai for free.

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



Editor of Machine Power Report: Wu Xin The domestic version of the humanoid robot + large model team completed the operation task of complex flexible materials such as folding clothes for the first time. With the unveiling of Figure01, which integrates OpenAI's multi-modal large model, the related progress of domestic peers has been attracting attention. Just yesterday, UBTECH, China's "number one humanoid robot stock", released the first demo of the humanoid robot WalkerS that is deeply integrated with Baidu Wenxin's large model, showing some interesting new features. Now, WalkerS, blessed by Baidu Wenxin’s large model capabilities, looks like this. Like Figure01, WalkerS does not move around, but stands behind a desk to complete a series of tasks. It can follow human commands and fold clothes

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.

DeepSeek is a powerful intelligent search and analysis tool that provides two access methods: web version and official website. The web version is convenient and efficient, and can be used without installation; the official website provides comprehensive product information, download resources and support services. Whether individuals or corporate users, they can easily obtain and analyze massive data through DeepSeek to improve work efficiency, assist decision-making and promote innovation.

There are many users in Xirang who don’t know where the shells are and how to get them. Some players have been searching for several hours but still can’t find them. Below, the editor will introduce how to obtain Baidu Xirang shells. Come and take a look. . How to get Baidu Xirang Shell 1. First we need to come to the community, and then come to the location in the picture below. 2. Select the destination here and choose to enter the 188th floor. 3. After entering the 188th floor, you will see this prompt when walking around. Just click I Got It. 4. The location of the shell may be a little difficult to find. Just behind the 188 elevator, there is a small glowing dot that is the shell. 5. You need to use a VR controller to pick up shells. Just click on the shell. Redemption method 1. First click the "Settings" icon in the upper right corner of the page and select "

On May 15, Baidu Apollo held Apollo Day 2024 in Wuhan Baidu Luobo Automobile Robot Zhixing Valley, comprehensively demonstrating Baidu's major progress in autonomous driving over the past ten years, bringing technological leaps based on large models and a new definition of passenger safety. With the world's largest autonomous vehicle operation network, Baidu has made autonomous driving safer than human driving. Thanks to this, safer, more comfortable, green and low-carbon travel methods are turning from ideal to reality. Wang Yunpeng, vice president of Baidu Group and president of the Intelligent Driving Business Group, said on the spot: "Our original intention to build autonomous vehicles is to satisfy people's growing yearning for better travel. People's satisfaction is our driving force. Because safety, So beautiful, we are happy to see

Detailed explanation of VSCode functions: How does it help you improve work efficiency? With the continuous development of the software development industry, developers' pursuit of work efficiency and code quality have become important goals in their work. In this process, the choice of code editor becomes a key decision. Among many editors, Visual Studio Code (VSCode for short) is loved by the majority of developers for its powerful functions and flexible scalability. This article will introduce some functions of VSCode in detail and discuss

"Understanding VSCode: What is this tool used for?" 》As a programmer, whether you are a beginner or an experienced developer, you cannot do without the use of code editing tools. Among many editing tools, Visual Studio Code (VSCode for short) is very popular among developers as an open source, lightweight, and powerful code editor. So, what exactly is VSCode used for? This article will delve into the functions and uses of VSCode and provide specific code examples to help readers

According to news from this site on May 7, on May 6, Robin Li, founder, chairman and CEO of Baidu, led a team to visit China National Petroleum Corporation (hereinafter referred to as "PetroChina") in Beijing and met with directors of China National Petroleum Corporation Chairman and Party Secretary Dai Houliang held talks. The two parties had in-depth exchanges on strengthening cooperation and promoting the deep integration of the energy industry with digital intelligence. PetroChina will accelerate the construction of a digital China Petroleum Corporation, strengthen cooperation with Baidu Group, promote the in-depth integration of the energy industry with digital intelligence, and make greater contributions to ensuring national energy security. Robin Li said that the "intelligent emergence" and core capabilities of understanding, generation, logic, and memory displayed by large models have opened up a broader space for imagination for the combination of cutting-edge technology and oil and gas business. Always
