Yii-kindediter-template edit, insert predefined Variables

Source: Internet
Author: User

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.

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.