FCKeditor使用方法小結

來源:互聯網
上載者:User
  用法: 1.我的網站目錄是www.裡面有如下檔案夾和檔案
  /www
      add.php
      /include
      /FCKeditor

        2.調用FCKeditor的方法:
          (1)在開頭包含include("FCKeditor/fckeditor.php")
          (2)在需要使用的的方加入
                       $oFCKeditor = new FCKeditor('FCKeditor1') ;//建立對象
            $oFCKeditor->BasePath = 'FCKeditor/' ;//FCKeditor所在的位置
            $oFCKeditor->ToolbarSet = 'Default' ;//工具按鈕
            $oFCKeditor->Create('EditorDefault', '60%',150) ;
           ?> 
            (此處basepath的路徑一定要和上面include的路徑一樣.否則會找不到檔案)
            另外,對於這個輸入內容的變數,如果要把它存入資料庫,它的變數名為你建
            立對象的名字.例如上面就是FCKeditor1 

         3.在FCKeditor/_samples/裡面有個php調用的例子.如simples01.php
           和sampleposteddata.php這兩個.後面那個檔案是輸出變數名的php
           程式,通過這個程式可以得到文本輸入框內容的變數名.

         4.配置 FCKeditor的toolbar功能按鈕可以很容易地進行定製,你可以依據你
           的需要在FCKeditor的設定檔FCKeditor/fck_config.js中進行定製
           ,一個功能按鈕對應一個唯一的名稱。 
           在fck_config.js中預設情況下已經設定好三種toolbar樣式:Default(包
           含全部功能),Accessibility和Basic。
讓我們先來看看toolbar樣式的定製格式:
config.ToolbarSets["ToolBarSetName"] = [ // Toolbar名
['Item 1','Item 2','-','Item 3','Item n'], // Toolbar第一行
['Item 4','-','Item 5','Item 6','Item n'] // Toolbar第二行
] ;
這裡'-'的作用是建立一個分割條。
FCKeditor1.6為我們提供了60個編輯功能,具體功能如下: 

功能名稱 含義 功能名稱 含義
EditSource 顯示HTML原始碼 StrikeThrough 刪除線
Save 儲存 Subscrīpt 下標
NewPage 建立空白頁面 Superscrīpt 上標
Preview 預覽 JustifyLeft 靠左對齊
Cut 剪下 JustifyCenter 置中對齊
Copy 複製 JustifyRight 靠右對齊
Paste 粘貼 JustifyFull 左右對齊
PasteText 純文字粘貼 InsertOrderedList 自動編號
PasteWord 來自Word的粘貼 InsertUnorderedList 項目符號
Print 列印 Outdent 減少縮排
SpellCheck 拼字檢查 Indent 增加縮排
Find 尋找 ShowTableBorders 顯示表格線
Replace 替換 ShowDetails 顯示明細
Undo 撤銷 Form 添加Form動作
Redo 還原 Checkbox 複選框
SelectAll 全選 Radio 選項按鈕
RemoveFormat 去除格式 Input 單行文字框
Link 插入/編輯 連結 Textarea 滾動文字框
RemoveLink 去除串連 Select 下拉式功能表
Anchor 錨點 Button 按鈕
Image 插入/編輯 圖片 ImageButton 圖片按鈕
Table 插入/編輯 表格 Hidden 隱藏
Rule 插入水平線 Zoom 顯示比例
SpecialChar 插入特殊字元 FontStyleAdv 系統字型
UniversalKey 軟鍵盤 FontStyle 字型樣式
Smiley 插入Emoji FontFormat 字型格式
About 關於 Font 字型
Bold 粗體 FontSize 字型大小
Italic 斜體 TextColor 文字顏色
Underline 底線 BGColor 背景色



    預設的Default包含了FCKeditor的全部功能,個人感覺有些功能用不上,完全載入還會影響顯示速度,所以我簡化了一下,只載入了一些常用的功能:
1、開啟FCKeditor/fck_config.js檔案,添加如下代碼
config.ToolbarSets["www"] = [
['EditSource','Save','NewPage','Preview','-','Cut','Copy','Paste','PasteText','-','Find','Replace','-','Undo','Redo','-','SelectAll','-','Link','RemoveLink','-','Image','Table','Rule','SpecialChar','Smiley'] ,
['Bold','Italic','Underline','-','JustifyLeft','JustifyCenter','JustifyRight','-','InsertOrderedList','InsertUnorderedList','-','Form','Checkbox','Radio','Input','Textarea','Select','Button','-','FontStyleAdv','TextColor'] ] ; 
  這樣載入的速度就快多了。
  使用時只需把$oFCKeditor->ToolbarSet = 'Default' 
  改為$oFCKeditor->ToolbarSet = 'www' 即可

           最後.我們把FCKeditor目錄下所有以底線“_”開頭的目錄都刪掉以節省空間的,如_test._samples,等等.完工

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.