Table of Contents
yii2 integrates Baidu editor umeditor, yii2 integrates umeditor
Home Backend Development PHP Tutorial yii2 integrates Baidu editor umeditor, yii2 integrates umeditor_PHP tutorial

yii2 integrates Baidu editor umeditor, yii2 integrates umeditor_PHP tutorial

Jul 12, 2016 am 08:54 AM
yii2 author Integrate Baidu editor

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.

Download

, 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']);  
    }
Copy after login

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

file
<?= $form->field($model, 'content')->textarea(['style' => 'width:760px;height:500px;']) ?>
Copy after login

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');
Copy after login

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); ?>
Copy after login

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1121983.htmlTechArticleyii2 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. You are welcome to reprint it, but you must...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

After 2 months, the humanoid robot Walker S can fold clothes After 2 months, the humanoid robot Walker S can fold clothes Apr 03, 2024 am 08:01 AM

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

Introduction to Go language development tools: a list of essential tools Introduction to Go language development tools: a list of essential tools Mar 29, 2024 pm 01:06 PM

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 web version entrance deepseek official website entrance deepseek web version entrance deepseek official website entrance Feb 19, 2025 pm 04:54 PM

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.

Introduction to how to obtain Baidu Xiyang Shells Introduction to how to obtain Baidu Xiyang Shells Mar 28, 2024 am 09:11 AM

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 "

Baidu Apollo releases Apollo ADFM, the world's first large model that supports L4 autonomous driving Baidu Apollo releases Apollo ADFM, the world's first large model that supports L4 autonomous driving Jun 04, 2024 pm 08:01 PM

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? Detailed explanation of VSCode functions: How does it help you improve work efficiency? Mar 25, 2024 pm 05:27 PM

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? Understanding VSCode: What is this tool used for? Mar 25, 2024 pm 03:06 PM

&quot;Understanding VSCode: What is this tool used for?&quot; 》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

Baidu Robin Li led a team to visit PetroChina to discuss the intelligence of the oil and gas industry Baidu Robin Li led a team to visit PetroChina to discuss the intelligence of the oil and gas industry May 07, 2024 pm 06:13 PM

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

See all articles