Yii add Baidu Editor Ueditor extension Example

Source: Internet
Author: User
Tags php file yii

This is someone else wrote a yii1 Baidu editor ueditor extension, webmaster I have used in their own projects, now record the usage and use of the problems.

Directory structure

Baiduueditor
|--resource//ueditor Resource Bundle
View of |--views//widget
|--config.php//Back-end configuration files include file format size directory path file name and so on
|--ueditorcontroller.php//back-end host controller can modify inheriting class to custom base class
|--ueditorwidget.php//widget main Render editor
|--uploader.class.php//uploading and other main processing classes

Use

1, copy the Baiduueditor to the protected/extensions/directory
2, add the following code to config/main.php


' Controllermap ' =>array (
' Ueditor ' =>array (
' Class ' => ' Ext.baiduUeditor.UeditorController ',
),
),

If you want to use only one module, add the following code to the Modules/modulename/modulenamemodule.php init method


$this->controllermap=array (
' Ueditor ' =>array (
' Class ' => ' Ext.baiduUeditor.UeditorController ',
),
);

Place the following code in the view where you want to display the editor


$this->widget (' Ext.baiduUeditor.UeditorWidget ',
Array
' ID ' => ' Article_content ',//container ID Unique [must be configured]
' Name ' => ' Content ',//post to background-received name [must be configured]
' Content ' => ',//initialize contents [OPTIONAL]

configuration options, [optional]
The Ueditor configuration items are passed in as array key-value pairs, specifically to view the Ueditor.config.js
Do not configure ServerURL (even if the configuration is overwritten) The program automatically processes the backend URL
' Config ' =>array (
' Toolbars ' =>array (Array (' fullscreen ', ' source ', ' | '),//toolbars note nested two arrays
' Lang ' => ' ZH-CN '
)
)
);
Following the steps above, the editor will definitely appear on the page without any surprises.

Problem: Upload pictures can not be reported, back-end configuration items do not load properly, upload plug-ins can not use the normal error.

Workaround: There is this ueditorcontroller.php file in the directory structure, please put this file in the Controller directory of your website, because upload the picture will eventually access to this file, my website access path is/admin/index.php?r= ueditor&action=config&&nocache=1464083990339, see this path should understand it. Do not understand in the group ask me! Group qq:66357155

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.