Yii-kindediter-模板编辑,插入预定义变量
来源:互联网 发布:城中大盗 知乎 编辑:程序博客网 时间:2024/06/06 13:04
1.修改YIi扩展目录下的Kdeditor.php 文件,把中的js对象声明放到方法外面
$js=<<<EOFvar editor_$this->id;KindEditor.ready(function(K) { editor_$this->id = K.create('#$this->id', $properties_string);});EOF;
2.视图文件代码
<li class="c_f"><span class="tit">模板变量:</span><div class="cont f_l"><?php foreach($templateVar as $key=>$val){?><span class="template_var" val="<?php echo $val?>"> <?php echo $key?> </span><?php }?></div></li>
<script type="text/javascript">$('.template_var').bind('click',function(){var str = $(this).attr('val');editor_EmailTemplates_zee_content.insertHtml(str);//editor_EmailTemplates_zee_content js编辑器对象名称});</script>
3.模型文件,后期处理
/** * 获取模板变量 */public function getVarUbb($type=null){if($type==null){return array('{username}'=>'{username}','{url}'=>'{url}','{sitename}'=>'{sitename}',);}}/** * 模板变量替换 */public function replaceVarUbb($str){$str = str_replace('{username}','<?php echo $params["username"]; ?>',$str);$str = str_replace('{url}','<?php echo $params["url"]; ?>',$str);$str = str_replace('{sitename}','<?php echo Yii::app()->name; ?>',$str);return $str;}/** * 模板保存后的操作 * 写入模板文件 */protected function afterSave(){$templatePath = Yii::app()->mailer->pathViews;$templatePath = str_replace('application','',$templatePath);$templatePath = str_replace('.','/',$templatePath);$templatePath = Yii::app()->basePath.$templatePath.'/';$templatePath = $templatePath.$this->zee_filename.'.php';$handle = fopen($templatePath, "wb");fwrite($handle, $this->replaceVarUbb($this->zee_content));fclose($handle);}
- Yii-kindediter-模板编辑,插入预定义变量
- ecshop模板标签的预定义变量
- perl预定义变量
- 预定义变量 $_SERVER
- PHP预定义变量
- 预定义变量
- Makefile 预定义变量
- PHP预定义变量
- MakeFile预定义变量
- PHP预定义变量
- GLSL预定义变量
- PHP 预定义变量
- linux预定义变量$@ $<
- 预定义变量
- PHP预定义变量
- 【笔记】预定义变量
- Linux预定义变量
- 预定义变量
- 读书笔记之《Data Structures With C++》
- Eclipse RCP 项目导出后中文乱码
- nsstring 字符转换
- phoneME Feature 实现代码目录描述
- Photoshop touch教程全攻略
- Yii-kindediter-模板编辑,插入预定义变量
- 10分钟了解C#中的协变和逆变
- 高精度加法
- VS中的语法高亮插件VisualAssistX10.7
- JS全局变量
- Android应用升级构想和要点总结
- Erp 公司系列:QAD
- 【vim】在vim中编译并调试C/C++的配置
- JS中定义对象方式四: 使用原型(prototype)方式创建对象之二(弊端及其改进)