• dedecms自定义模型内容调用多个Ueditor


    关于dedecms后台如何整合百度编辑器(ueditor)网上有很多了,本站就不再赘述了,主要问题是,涉及到如果有内容模型的修改,则按照网络上介绍的方法会发现有BUG。当修改过默认的文章模型或者其他模型,有添加自定义字段,字段类型是HTML格式或者文本保存HTML格式,当你发布或者编辑内容的时候,发现要么是只有一个编辑器出来,要么是一旦保存完内容再次打开编辑的时候,百度编辑器的内容都是一样的了。主要原因在于/include/inc/inc_fun_funAdmin.php 文件内实例化编辑器的时候出现JS和CSS引用重复的问题:

     

    else if($GLOBALS['cfg_html_editor']=='ueditor1.4.3')
        {
            $fvalue = $fvalue=='' ? '<p></p>' : $fvalue;
            $code = '<script type="text/javascript" charset="utf-8" src="'.$GLOBALS['cfg_cmspath'].'/include/ueditor1.4.3/ueditor.config.js"></script>';
         $code .= '<script type="text/javascript" charset="utf-8" src="'.$GLOBALS['cfg_cmspath'].'/include/ueditor1.4.3/ueditor.all.min.js"></script>';
            $code .= '<link rel="stylesheet" type="text/css" href="'.$GLOBALS['cfg_cmspath'].'/include/ueditor1.4.3/themes/default/css/ueditor.css"/>';
            //$code .= '<textarea name="'.$fname.'" id="'.$fname.'" style="100%;">'.$fvalue.'</textarea>';
            $code .= '<script type="text/plain" name="'.$fname.'" id="'.$fname.'">'.$fvalue.'</script>';
            if( !empty($toolbar[$etype]))
            {
                $code .= '<script type="text/javascript">UE.getEditor("'.$fname.'",{toolbars:[["Source","|",
            "bold", "italic", "underline","|","fontsize","forecolor","emotion","Undo", "Redo"]],initialFrameHeight:100});</script>';
            }
            else
            {
                $code .= '<script type="text/javascript">UE.getEditor("'.$fname.'",{initialFrameHeight:450});</script>';
            }        
                                                                                                      
            if($gtype=="print")
            {
                echo $code;
            }
            else
            {
                return $code;
            }
        }

     

    注意上面2个JS和CSS文件,当有ueditor实例化的时候他们就被引用一次,因此后一次的总会覆盖前面一次的。解决方法很简单,将上面3行代码从此处移走

     

    <script type="text/javascript" charset="utf-8" src="'.$GLOBALS['cfg_cmspath'].'/include/ueditor1.4.3/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="'.$GLOBALS['cfg_cmspath'].'/include/ueditor1.4.3/ueditor.all.min.js"></script>
    <link rel="stylesheet" type="text/css" href="'.$GLOBALS['cfg_cmspath'].'/include/ueditor1.4.3/themes/default/css/ueditor.css"/>
    

     放到/dede/templates/

    article_add.htm
    article_edit.htm
    archives_add.htm
    archives_edit.htm
    catalog_add.htm
    catalog_edit.htm

    以上几个文件,及其他的文件的<head>里面,这样每次不管是添加还是编辑文章模型或者其他的自定义模型都不会出现问题了。需要注意的是,上面3行代码请全部换成纯静态地址,以免代码无效。

  • 相关阅读:
    Hadoop出现 Wrong FS: hdfs://......错误的解决方法
    在Linux下安装JDK环境
    卸载Linux自带的JDK
    hadoop1.2.1伪分布模式安装教程
    spring配置bean的生命周期
    spring注入的四种方式
    python re模块search()与match()区别
    VB.NET操作Excel
    位运算
    Python简单源码解析
  • 原文地址:https://www.cnblogs.com/xinhudong/p/10158973.html
Copyright © 2020-2023  润新知