為織夢dedecms不同頁面中百度ueditor編輯器設置不同寬度_建站經驗教程

      編輯Tag賺U幣
      教程Tag:暫無Tag,歡迎添加,賺取U幣!

      推薦:PSD轉div css網頁切圖示例
      第一步:先把把所有標記歸置內外邊距歸置為0,其實還有一種方法是根據根據BODY里面所用到的HTML標記進行重置為0.你也可以先用*重置為0然后在 根據BODY中所使用的標記進行重置.如:我們BODY標記中使用了,div,p那我們的選擇符就寫body,div,p就可以了.不需要寫*了. *{ margin

             相信正在使用織夢dedecms作為網站管理程序的站長朋友對dedecmsmoban/">織夢自帶的ckeditor編輯器一定感到非常糾心:其難看的外觀,不太好用的添加視頻功能,超級弱智的圖片上傳項,就連按個"tab"鍵都要跳出編輯框...這些無不讓我們對其深惡痛絕(可能說得有點夸張)!

             本人最近開了一個新站,最初因為這個ckeditor編輯器給編輯工作帶來了諸多不便,所以最后痛下決心:改成百度ueditor

             為什么改成ueditor而不是別的編輯器呢?原因主要有三點:

             一、ueditor界面相當美觀,用起來舒服;

             二、功能強悍,比如圖片上傳功能:它支持批量上傳,圖片搜索,還有非常不錯的圖片管理器;再比如視頻添加功能:直接填寫優酷土豆等視頻網址即可,不用像ckeditor那樣非常麻煩地去找".swf"flash地址;

             三、基于百度雄厚的實力,相信這個ueditor功能也會越來越強大。

            是不是心動了?想體驗ueditor的朋友可以去我的小創意網(www.smallcy.com)看看,相信會帶給你不錯的體驗。

            不過ueditor裝上后也不是馬上就能用的(至于怎么安裝,大家可以在官方論壇上找),一般都會存在一些小問題。下面我就來談談其中一個非常重要的問題的解決方案。

             安裝完ueditor后,我們可以在ueditor的配置文件中對其界面寬度進行設置,但問題就出在這里,在這里設置的寬度是對全局而言,即所有網站內的編輯器寬度都一樣。但對于我們dedecms用戶而言,一般前臺和后臺編輯器寬度不一致,這樣就會造成編輯器越界的問題。解決方案:將ueditor寬度設置放在編輯器調用階段,具體做法如下:

      1. /include/helpers/util.helper.php中增加以下代碼

      if ( ! function_exists('GetEditorD'))

      {

          function GetEditorD($fname, $fvalue, $nheight="350", $etype="Basic", $gtype="print", $isfullpage="FALSE",$bbcode=false)

          {

              if(!function_exists('SpGetEditorD'))

              {

                  require_once(DEDEINC."/inc/inc_fun_funAdmin.php");

              }

              return SpGetEditorD($fname, $fvalue, $nheight, $etype, $gtype, $isfullpage, $bbcode);

          }

      }

      2. /include/inc/inc_fun_funAdmin.php中增加以下代碼:

      function SpGetEditorD($fname,$fvalue,$nheight="350",$etype="Basic",$gtype="print",$isfullpage="false",$bbcode=false)

      {

          global $cfg_ckeditor_initialized;

          if(!isset($GLOBALS['cfg_html_editor']))

          {

              $GLOBALS['cfg_html_editor']='fck';

          }

          if($gtype=="")

          {

              $gtype = "print";

          }

          if($GLOBALS['cfg_html_editor']=='fck')

          {

              require_once(DEDEINC.'/FCKeditor/fckeditor.php');

              $fck = new FCKeditor($fname);

              $fck->BasePath        = $GLOBALS['cfg_cmspath'].'/include/FCKeditor/' ;

              $fck->Width        = '100%' ;

              $fck->Height        = $nheight ;

              $fck->ToolbarSet    = $etype ;

              $fck->Config['FullPage'] = $isfullpage;

              if($GLOBALS['cfg_fck_xhtml']=='Y')

              {

                  $fck->Config['EnableXHTML'] = 'true';

                  $fck->Config['EnableSourceXHTML'] = 'true';

              }

              $fck->Value = $fvalue ;

              if($gtype=="print")

              {

                  $fck->Create();

              }

              else

              {

                  return $fck->CreateHtml();

              }

          }

          else if($GLOBALS['cfg_html_editor']=='ckeditor')

          {

              require_once(DEDEINC.'/ckeditor/ckeditor.php');

              $CKEditor = new CKEditor();

              $CKEditor->basePath = $GLOBALS['cfg_cmspath'].'/include/ckeditor/' ;

              $config = $events = array();

              $config['extraPlugins'] = 'dedepage,multipic,addon';

                if($bbcode)

                {

                     $CKEditor->initialized = true;

                     $config['extraPlugins'] .= ',bbcode';

                     $config['fontSize_sizes'] = '30/30%;50/50%;100/100%;120/120%;150/150%;200/200%;300/300%';

                     $config['disableObjectResizing'] = 'true';

                     $config['smiley_path'] = $GLOBALS['cfg_cmspath'].'/images/smiley/';

                     // 獲取表情信息

                     require_once(DEDEDATA.'/smiley.data.php');

                     $jsscript = array();

                     foreach($GLOBALS['cfg_smileys'] as $key=>$val)

                     {

                          $config['smiley_images'][] = $val[0];

                          $config['smiley_descriptions'][] = $val[3];

                          $jsscript[] = '"'.$val[3].'":"'.$key.'"';

                     }

                     $jsscript = implode(',', $jsscript);

                     echo jsscript('CKEDITOR.config.ubb_smiley = {'.$jsscript.'}');

                }

       

              $GLOBALS['tools'] = empty($toolbar[$etype])? $GLOBALS['tools'] : $toolbar[$etype] ;

              $config['toolbar'] = $GLOBALS['tools'];

              $config['height'] = $nheight;

              $config['skin'] = 'kama';

              $CKEditor->returnOutput = TRUE;

              $code = $CKEditor->editor($fname, $fvalue, $config, $events);

              if($gtype=="print")

              {

                  echo $code;

              }

              else

              {

                  return $code;

              }

          }else if($GLOBALS['cfg_html_editor']=='ueditor')

      {

              $fvalue = $fvalue=='' ? '<p></p>' : $fvalue;

              $code = '<script type="text/javascript" charset="gbk" src="'.$GLOBALS['cfg_cmspath'].'/include/ueditor/editor_config.js"></script>

              <script type="text/javascript" charset="gbk" src="'.$GLOBALS['cfg_cmspath'].'/include/ueditor/editor_all_min.js"></script>

              <link rel="stylesheet" type="text/css" href="'.$GLOBALS['cfg_cmspath'].'/include/ueditor/themes/default/ueditor.css"/>

              <textarea name="'.$fname.'" id="'.$fname.'" style="width:100%;">'.$fvalue.'</textarea>

              <script type="text/javascript">

              var ue = new baidu.editor.ui.Editor({ initialFrameWidth:824 });ue.render("'.$fname.'");     //紅色處為修改寬度

              </script>';

              if($gtype=="print")

              {

                      echo $code;

              }

              else

              {

                      return $code;

              }

      }

       

          else {

              /*

              // ------------------------------------------------------------------------

              // 當前版本,暫時取消dedehtml編輯器的支持

              // ------------------------------------------------------------------------

              require_once(DEDEINC.'/htmledit/dede_editor.php');

              $ded = new DedeEditor($fname);

              $ded->BasePath        = $GLOBALS['cfg_cmspath'].'/include/htmledit/' ;

              $ded->Width        = '100%' ;

              $ded->Height        = $nheight ;

              $ded->ToolbarSet = strtolower($etype);

              $ded->Value = $fvalue ;

              if($gtype=="print")

              {

                  $ded->Create();

              }

              else

              {

                  return $ded->CreateHtml();

              }

              */

          }

      }

      3. 在編輯器調取頁面將以下代碼:

      <?php GetEditor("body","",350,"Member"); ?>

      改為:

      <?php GetEditorD("body","",350,"Member"); ?>

      以上方案的思想是:在不同界面使用不同的編輯器調用函數。

      當然你可以根據需要對以上代碼進行刪改,還有什么問題可以去小創意網(www.smallcy.com)咨詢。

      分享:小網站大精彩 找特色就不懼發展瓶頸
      最近看到幾篇都有這樣的思路,那些很小的網站,然后做出了一些其他網站并沒有的優勢,比如說,放棄google的工作,然后回家創業,比如說那個專門賣襪子的網站,然后發展出了自己的潛力,讓更多的訂單出現而來,其實很多時候,在國內的互聯網中,也慢慢的成熟起來,這種

      來源:模板無憂//所屬分類:建站經驗教程/更新時間:2013-04-17
      相關建站經驗教程