思路,做爲一個編輯器插件 FCKeidtor能夠說功能很是全面,下面簡單說下如何在本身的開發項目中使用這個插件php
首先,下載到FCKeidtor這個軟件包 點擊下載html
而後解壓縮複製到項目根目錄 並更名爲比較簡單的名字 editor服務器
首先打開fckeidtor.php 發現做用是判斷服務器的PHP版本,4.0就引入4.0的類,5.0就引入5.0的類編輯器
- if ( !function_exists('version_compare') || version_compare( phpversion(), '5', '<' ) )
- include_once( 'fckeditor_php4.php' ) ;
- else
- include_once( 'fckeditor_php5.php' ) ;
而後新建一個PHP頁面 new_add.php 內容以下ide
- <?
- /*用include方法加載類的文件,這個文件會自動判斷服務器的PHP版本,4.0自動調用4.0的類,5.0調用5.0的類*/
- include ("editor/fckeditor.php");
- $oBasePath = $_SERVER['PHP_SELF'];//用$_SERVER函數獲得當前文件的實際路徑,這裏包括文件名
- /*用dirname函數獲得去掉文件名的路徑加上/editor/獲得FCKeditor的路徑*/
- $oBasePath = dirname ($oBasePath)."/editor/";
- $ed = new FCKeditor("con"); //實例化FCKeditor對象 給name爲con
- $ed->BasePath = $oBasePath; //程序的地址爲上面獲得的路徑
- //$ed->ToolbarSet = "Basic"; 是否使用簡單模式的開關
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>無標題文檔</title>
- </head>
- <body>
- <?
- if($_POST[sub])//判斷$_POST[sub]是否爲真,真爲有內容提交
- {
- $con = $_POST[con];//讀取FCKeditor中的內容
- $con = str_replace('\\','',$con); //替換\爲空,爲了讓網址能正常顯示
- echo "文章標題:".$_POST[title].
- "<br>文章內容".$con; //輸出接收的內容
- }
- ?>
- <form method="post" action="">
- 文章標題<input type="text" name="title" />
- <? $ed->Create(); //建立一個FCKeditor的窗口?>
- <input type="submit" name="sub" value="提交新聞" />
- </form>
- </body>
- </html>
最重要的步驟是 函數
若是要FCKeditor能夠上傳圖片的話,要開啓editor\editor\filemanager\connectors\php\config.php裏面post
找到 $Config['Enabled'] = false; 這是默認的ui
修改成 $Config['Enabled'] = true ;spa
找到$Config['UserFilesPath'] = '/userfiles/' ; 這是上傳文件的路徑改成本身的路徑插件
如 $Config['UserFilesPath'] = '/class/userfiles/' ; 就是個人localhost/class/路徑下的userfiles文件夾