Home Backend Development PHP Tutorial A brief analysis of Yii2 integrated rich text editor redactor example tutorial php rich text editor java rich text editor jsp rich text editor

A brief analysis of Yii2 integrated rich text editor redactor example tutorial php rich text editor java rich text editor jsp rich text editor

Jul 29, 2016 am 08:51 AM
Rich text editor

In the previous article, I introduced to you how to integrate Baidu editor umeditor in yii2 and how to solve the problem of umeditor uploading pictures.

Today we will talk about the integration of yii2 with another powerful and easy-to-use rich text editor, Redactor. Personally, I think Redactor is easier to use than Baidu Editor.

Redactor has an official Yii2 plug-in package, which is also very practical.

First of all, let’s not be impatient and install Redactor first.

You can refer to https://github.com/yiidoc/yii2-redactor for installation. There are many novices who cannot understand English. If you click on the link and refer to the installation on github, I hope you will come back to see what necessary precautions are required during the entire installation process.

1. Just like them, we can use composer to install it.

2. Add configuration items

'modules' => [ 
'redactor' => [ 
'class' => 'yii\redactor\RedactorModule', 
'uploadDir' => '上传目录', 
'uploadUrl' => '图片可访问地址', 
'imageAllowExtensions'=>['jpg','png','gif'] 
], 
],
Copy after login

The first point to note is that the default uploaded files are saved in uploads in the root directory. If you want to change the saving directory of the files, just modify the configuration item uploadDir. At the same time, you need to modify uploadUrl ensures that the image is accessible. 3. If your view is of ActiveField type, the following configuration applies to you

<&#63;= $form->field($model, 'content')->widget(\yii\redactor\widgets\Redactor::className()) ?>
Copy after login

But if your form is not generated using Yii’s own components, you should configure it as follows

<&#63;= \yii\redactor\widgets\Redactor::widget([ 'model' => $model, 'attribute' => 'content' ]) ?>
Copy after login

4. Upload it The class uses a redactor set, but you said that your upload class needs to be rewritten, that’s fine, you just need to add a few configurations like the following

<&#63;= $form->field($model, 'content')->widget(\yii\redactor\widgets\Redactor::className(), [ 
'clientOptions' => [ 
'imageManagerJson' => ['/redactor/upload/image-json'], 
'imageUpload' => ['/redactor/upload/image'], 
'fileUpload' => ['/redactor/upload/file'], 
'lang' => 'zh_cn', 
'plugins' => ['clips', 'fontcolor','imagemanager'] 
] 
]) ?>
Copy after login

5. Configure language or plug-in, like step 4 , just add the lang and plugins configuration items in the clientOptions item. If you want to ask what plugins there are, open the directory vendorii2-redactorassetsplugins to have a look.

6. Be careful when uploading images, because redactor is introduced as a module. If your project contains permission management, remember to add permissions.

7. I forgot a major premise, make sure your php supports fileinfo extension. Open the php.ini file and remove the semicolon in front of fileinfo

The above is the Yii2 integrated rich text editor redactor example tutorial introduced by the editor. I hope it will be helpful to everyone!

The above has introduced a brief analysis of the Yii2 integrated rich text editor redactor example tutorial, including the content of the rich text editor. I hope it will be helpful to friends who are interested in PHP tutorials.

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

Video Face Swap

Video Face Swap

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

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)

Create a rich text editor using PHP and CKEditor Create a rich text editor using PHP and CKEditor May 11, 2023 pm 04:06 PM

With the widespread use of web applications, creating rich text editors has become more and more common. CKEditor is widely recognized as one of the best rich text editors because of its good customizability and ease of use. This article will introduce how to create a rich text editor using PHP and CKEditor. Introduction to CKEditor CKEditor is an open source, cross-platform rich text editor implemented through JavaScript. It provides an intuitive and easy-to-understand toolbar, including font style, formatting, graphics, etc.

How to use Java to write a rich text editor module for a CMS system How to use Java to write a rich text editor module for a CMS system Aug 04, 2023 pm 06:57 PM

How to use Java to write a rich text editor module for a CMS system. In modern website development, the Content Management System (CMS) plays a crucial role. The rich text editor module is an indispensable part, which allows website administrators to easily edit and publish content. This article will introduce how to use Java to write a rich text editor module for a CMS system and provide code examples. 1. Choose the right rich text editor to start with

How to implement rich text editor in uniapp How to implement rich text editor in uniapp Jul 04, 2023 pm 12:17 PM

How to implement a rich text editor in uniapp In many applications, we often encounter situations where users need to input rich text content, such as editing articles, publishing updates, etc. To meet this requirement, we can use a rich text editor. In uniapp, we can use some open source rich text editor components, such as wangeditor, quill, etc. Below, I will use wangeditor as an example to introduce how to implement rich text editing in uniapp.

How to use PHP to develop a rich text editor in a CMS How to use PHP to develop a rich text editor in a CMS Jun 21, 2023 am 11:20 AM

With the development of the Internet, more and more websites are beginning to use CMS (content management system) to manage their content. The rich text editor is an integral part of these CMS, which allows users to easily edit, format and publish content. In this article, we will introduce how to use PHP to develop a rich text editor in a CMS. 1. What is a rich text editor? A rich text editor is a text editor that can render multiple formats, allowing users to use various styles for typesetting operations without having to learn HTML or C

Rich text editor skills in mall development (29 words) Rich text editor skills in mall development (29 words) Jun 30, 2023 pm 09:03 PM

Rich text editor function implementation tips in PHP Developer City With the rapid development of the Internet, more and more malls use online editors to provide rich text editing functions, allowing users to design their own product details pages through simple operations. When developing PHP, how to implement rich text editor functions is a key technical problem. This article will introduce some techniques for implementing rich text editor functions to help PHP developers better complete this task. 1. Choose a suitable rich text editor When choosing a rich text editor, we

Common rich text editor controls in Go language web development framework Common rich text editor controls in Go language web development framework Jun 04, 2023 am 09:10 AM

With the popularity of web applications, rich text editors have become an indispensable tool in web development. When using Go language for web development, we also need to choose a suitable rich text editor control to enrich our websites and applications. In this article, we will discuss common rich text editor controls in Go language web development. FroalaEditorFroalaEditor is a popular rich text editor control that is widely used in web development. it has modernity

How to use the rich text editor plug-in to implement rich text editing function in uniapp How to use the rich text editor plug-in to implement rich text editing function in uniapp Oct 20, 2023 am 10:31 AM

Overview of how to use the rich text editor plug-in to implement rich text editing functions in uniapp In modern applications, the rich text editor is a must-have feature because it allows users to create rich and diverse text content in the application, including font styles, Font size, color, insert pictures, etc. As a cross-platform development framework, uniapp also provides a way to use rich text editor plug-ins to achieve this function. This article will introduce how to use the rich text editor plug-in in uniapp and give specific code examples. step import

How to use the Layui framework to develop a web page editing function that supports rich text editor How to use the Layui framework to develop a web page editing function that supports rich text editor Oct 24, 2023 am 08:16 AM

Title: Using the Layui framework to develop web page editing functions that support rich text editors Introduction: In web development, web page editing functions are a common and important module. In order to improve user experience, supporting rich text editors is essential. This article will introduce how to use the rich text editor component in the Layui framework for development and provide specific code examples. 1. Introduction to Layui framework Layui is a front-end UI framework based on HTML5 and CSS3 technology. It is committed to providing simple, easy-to-use components and rich

See all articles