Yii2 integrates Baidu editor umeditor and yii2 integrates umeditor. Yii2 integration Baidu editor umeditor, yii2 integration umeditor author: White Wolf Source: www. manks. this article is copyrighted by the Author. You are welcome to reprint it. However, without the consent of the Author, yii2 must be integrated with Baidu editor umeditor and yii2 umeditor.
Author: White Wolf Source: www. manks. top/article/yii2_umeditor
The copyright of this article belongs to the Author. You are welcome to repost this article, but you must keep this statement without the author's consent and provide the original article connection clearly on the article page. Otherwise, you will be entitled to pursue legal liability.
In actual work, similar news, articles, and other development work will inevitably not be encountered. This requires the operation staff to release the work. However, some friends, in order to save trouble, OK. it is online. My sister from other people is trying it out. Hey, you have published a big article for me.textarea
Even if you're done, you don't want to be able to publish a piece of news. Let's talk about it next.Yii2
How is the framework integrated with Baidu editor?umeditor
.
umeditor
What is it?ueditor
, Youumeditor
Is it pirated dongdongnan?umeditor
In other words, the mini version is used.ueditor
According to Baidu official statement, it is actually the "short soft and small" in the editor, but the feature is incomplete. Ke, let's get back to the question.
First, let's download a mini ueditor on the official website.umeditor
Yes.um editor
.
Download and decompress the package to the project root directory. /css
The directory is namedumeditor
The specific location can be referenced later.
Step 2: Expandbackend\assets\Appset
Class, oh, why do we need to expand this stuff?umeditor
The integration of what relationship leader, half-way to kill a process of gold. The purpose of extending this class file here is to facilitate the introduction of this class file in the file.css
js
File drop.
Very simpleAppset
Add the following two methods to the method:
// Define the JS method to be loaded as needed. pay attention to the loading order in the final public static function addScript ($ view, $ jsfile) {$ view-> registerJsFile ($ jsfile, [AppAsset :: className (), 'desc' => 'backend \ assets \ appasset']);} // defines the on-demand loading css method, note that the loading sequence is in the final public static function addCss ($ view, $ cssfile) {$ view-> registerCssFile ($ cssfile, [AppAsset: className (), 'desc' => 'backend \ assets \ appasset']);}
Next, follow the configuration below.
First, let's assume there is an articlearticle
Table with a contentcontent
The field must be displayed as the Baidu editor.
Followyii2
According to the form model, we modifyarticle\_form.php
Filecontent
Field
field($model, 'content')->textarea(['style' => 'width:760px;height:500px;']) ?>
This file is introducedAppset
Class and introduce relatedCss js
The file is 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 followingjs
Code
beginBlock('js-block') ?> $(function () { var um = UM.getEditor('article-content', { }); });
endBlock() ?>
registerJs($this->blocks['js-block'], \yii\web\View::POS_END); ?>
Aboutarticle-content
This is the target object to be bound, that isContent.article-content
Is the current object'sid
ID.
OK. The Baidu editor is basically integrated here. Now, add an article and try again. remember to update it to see if there is any content in the editor.
Author: White Wolf Source: www. manks. top/article/yii2_umeditor this article is copyrighted by the Author. You are welcome to reprint it, but it is required without the author's consent...