Yii2 百度编辑器小部件
来源:互联网 发布:阿里云php环境搭建 编辑:程序博客网 时间:2024/05/21 16:55
Yii2 百度编辑器小部件Ueditor.php
<?phpnamespace common\components;use yii\helpers\Html;use yii\helpers\Json;use yii\widgets\InputWidget; /* * 创建百度编辑器插件 * 2015年11月22日12:41:25 * 滴水湖 宜浩佳园 111弄 55号 */class Ueditor extends InputWidget{ public $attributes; public function init() { parent::init(); } public function run() { $view = $this->getView(); $this->attributes['id']=$this->options['id']; if($this->hasModel()){ $input=Html::activeTextarea($this->model, $this->attribute,$this->attributes); }else{ $input=Html::textarea($this->name,'',$this->attributes); } echo $input; UeditorAsset::register($view);//将Ueditor用到的脚本资源输出到视图 $js='var ue = UE.getEditor("'.$this->options['id'].'",'.$this->getOptions().');';//Ueditor初始化脚本 $view->registerJs($js, $view::POS_END);//将Ueditor初始化脚本也响应到视图中 } public function getOptions() { unset($this->options['id']);//Ueditor识别不了id属性,故而删之 return Json::encode($this->options); }}?>UeditorAsset.php
<?phpnamespace common\components;use yii\web\AssetBundle; /* * 创建百度编辑器插件 * 2015年11月22日12:41:25 * 滴水湖 宜浩佳园 111弄 55号 */class UeditorAsset extends AssetBundle{ public $js = [ 'ueditor.config.js', 'ueditor.all.js', ]; public $css = [ ]; public function init() { $this->sourcePath =$_SERVER['DOCUMENT_ROOT'].\Yii::getAlias('@web').'/staic/ue'; //设置资源所处的目录 }}
引用 部分 主要命名空间的我这里是
use common\components\Ueditor;
<?= $form->field($model, 'content')->widget(Ueditor::className(),[ 'options'=>[ 'focus'=>true, 'toolbars'=> [ [ 'source', //源代码 'anchor', //锚点 'undo', //撤销 'redo', //重做 'bold', //加粗 //.......................省略 ] ], ], 'attributes'=>[ 'style'=>'height:80px' ]]) ?>
0
0 0
- Yii2 百度编辑器小部件
- Yii2.0-Widget小部件制作
- [widget] -- yii2小部件高级使用
- Yii2自定义Widget,百度编辑器
- yii2.0-Ueditor百度编辑器
- (十三) yii2 checkboxList小部件默认选中
- 7 yii2.0小部件管理布局的高级使用
- yii2.0 表单小部件常用的默认选中
- Yii2.0小部件GridView(数据展示)①
- Yii2.0小部件GridView(两表联查/搜索/分页)②
- yii2 表单小部件默认选中的方法
- yii2 如何使用数据小部件之DetailView
- Yii2.0使用百度文本编辑器Ueditor
- YII2下使用百度编辑器扩展yii2-ueditor
- YII2下使用百度编辑器扩展yii2-ueditor(二)
- yii2解决百度编辑器umeditor图片上传问题
- 小部件
- 小部件
- c++ STL 算法库用法
- Android 屏幕适配
- java 排序算法
- 编译Linux kernel时设置交叉编译器
- EqualsBuilder和HashCodeBuilder
- Yii2 百度编辑器小部件
- Linux命令简介—ls
- 万金难买早知道
- 【转】一些Mat函数
- 1014. 福尔摩斯的约会 (20)
- 既然选择远方,就应该高高兴兴的走下去
- 获取子进程终止状态:wait和waitpid
- webWorker操作
- PHP7 RC7 Release对比PHP5.6快速排序20000数据性能体验以及新语法尝鲜