Skip to content
CodingThailand's Blog
CodingThailand's Blog

by โค้ชเอก

  • Home
  • About Me
  • CodingThailand.com
CodingThailand's Blog

by โค้ชเอก

แนะนำ WYSIWYG editor ใช้กับ Yii2 Framework

14/05/2016

สำหรับใครที่กำลังมองหา WYSIWYG editor ของ Yii2 Framework แนะนำตัวนี้เลยครับ yii2-redactor คุณสมบัติหลักๆ ที่ชอบคือมันสวย ใช้ง่าย มีระบบจัดการรูปภาพ และจัดการไฟล์มาให้เรียบร้อย!! ลิงก์ตามนี้ https://github.com/yiidoc/yii2-redactor

 

1. หลังจากติดตั้งเสร็จ เปิดไฟล์ common\config\main.php ขึ้นมาแล้วเพิ่ม module ครับ

'modules' => [
'redactor' => [
'class' => 'yii\redactor\RedactorModule',
'uploadDir' => 'C:\xampp\htdocs\inpiredev\uploads',
'uploadUrl' => '@web/uploads',
'imageAllowExtensions'=>['jpg','png','gif']
],
],

หมายเหตุ ตรง uploadDir และ uploadUrl ใส่เป็นเว็บของตัวเองนะครับ

2. ไปที่ View ของโปรเจคเรา สมมติว่าเป็นไฟล์ _form.php แล้วแทรกโค้ด ดังนี้

<?= $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' => 'th',
'minHeight' => 300,
'plugins' => ['clips', 'fontcolor','imagemanager']
]
])?>

เรียบร้อย!! ถ้าอยากรู้ว่ามี options อะไรเพิ่มเติมอีกก็ตามไปได้ที่เว็บ http://imperavi.com/redactor

Views: 1144

Yii

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Posts ล่าสุด

  • การใช้งาน Prefetching ใน Next.js
  • 14 ข้อคิด เพื่อการเป็น Developer ที่ดีขึ้น จาก “Lee Robinson”
  • เคยเจอ “TypeError: Cannot read property ‘x’ of undefined” หรือเปล่า
  • บันทึกการเขียนเว็บไซต์ใหม่ในรอบ 10 ปี ย้ายมาใช้ Next.js
  • ทำไมการจัดการ Error ใน JavaScript ถึงเป็นเรื่องท้าทาย?

Recent Comments

    หมวดหมู่

    • .NET
    • AI
    • Android
    • Angular
    • Angular 2
    • Coding
    • CSS
    • Database
    • Editor
    • Flutter
    • Git
    • HTML5
    • Ionic 2
    • Ionic 4
    • Ionic Framwork
    • JavaScript
    • Laravel
    • Laravel 5
    • Next.js
    • Node.js
    • PHP
    • PHP 7
    • Plugins
    • React
    • React Native
    • Template
    • Tools
    • TypeScript
    • UI
    • Uncategorized
    • Vue.js
    • XAMPP
    • Yii
    • คอร์สเรียน
    • แรงบันดาลใจ

    Archives

    • July 2025
    • April 2025
    • November 2024
    • October 2024
    • April 2020
    • February 2020
    • August 2019
    • September 2018
    • August 2018
    • February 2018
    • November 2017
    • October 2017
    • August 2017
    • July 2017
    • April 2017
    • October 2016
    • August 2016
    • May 2016

    Tags

    .NET android Angular Angular 2 Atom Coding Coding Standard CSS CSS 3 Datepicker Express.js extensions Git HTML HTML5 Ionic2 JavaScript Laravel5 laravel 5.5 MariaDB Material Design MySQL Node.js npm PHP PHP7 plugins PouchDB recaptcha Restful sail.js template typescript typscript XAMPP Yii2

    ผู้เยี่ยมชม

    • 0
    • 1,818,217
    • 547,579
    • 1,144
    ©2025 CodingThailand's Blog | WordPress Theme by SuperbThemes