Yii-kindediter-template editing, inserting predefined variables_PHP tutorial

WBOY
Release: 2016-07-14 10:09:25
Original
906 people have browsed it

1. Modify the Kdeditor.php file in the YIi extension directory and put the js object declaration outside the method.

[html]
$js=<<
var editor_$this->id;
KindEditor.ready(function(K) {
editor_$this->id = K.create('#$this->id',
$properties_string
);
});
F;
2. View file code
[html]
  • Template variable:
  • $val){?>
                                                                                                                                                                                  
    [html]
    3. Model file, post-processing
    [html]
    /**
    * Get template variables
    */
    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}','',$str);
    $str = str_replace('{url}','',$str);
    $str = str_replace('{sitename}','name; ?>',$str);
    return $str;
    }
    /**
    * Operations after saving the template
    * Write 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. Rendering
    Yii-kindediter-template editing, inserting predefined variables_PHP tutorial

    http://www.bkjia.com/PHPjc/477650.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477650.htmlTechArticle1. Modify the Kdeditor.php file in the YIi extension directory and put the js object declaration outside the method [ html] $js=EOF var editor_$this-id; KindEditor.ready(function(K) { editor_$this-id = K.c...
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!