用法:
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,等等.完工