1. modify Kdeditor in the YIi extension directory. php file, put the js object declaration in the method outside [html] $ js = <EOF var editor _ $ this-> id; KindEditor. ready (function (K) {editor _ $ this-> id = K. create ('# $ this-> id', $ properties_string) ;}); F; 2. view File Code [html] <li class = "c_f"> <span class = "tit"> template variable: </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> [html] <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 editor object name}); </script> 3. model file, post-processing [html]/*** get template variable */public function getVarUbb ($ type = null) {if ($ type = null) {return array ('{username}' => '{username}', '{url}' => '{url}', '{sitename}' => '{Sitename}',) ;}}/*** template variable replacement */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;}/*** operation after saving the template * write the template file */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);} 4.