php在頁面中調用fckeditor編輯器的代碼
來源:程序員人生 發布時間:2014-06-14 11:28:01 閱讀次數:3742次
關于FckEditor的文章,學院以前介紹了一些,今天再來說一下如何使用PHP調用FCK編輯器,fckeditor編輯器的代碼可以寫成一個函數或者類別,直接調用,不用每次都要寫那么多代碼!剛才在論壇上看到一個童鞋分享的方法,感覺不是很全面,現在分享下我的!
PHP頁面:
/* 編輯器 */
include_once "../include/fckeditor/fckeditor.php";//把編輯器引進來
$editor = new FCKeditor('content');//表單項的名稱
$editor->BasePath = "/fckeditor/";//編輯器所在目錄
$editor->ToolbarSet = "Normal";//工具欄的名字,可以根據自己的需求加載其他的
$editor->Width = "95%";//寬度度
$editor->Height = "250";//高度
$editor->Value = $content;//初始值
$fckeditor = $editor->CreateHtml();//在要顯示編緝器的地方輸出變量$fckeditor的值就行了
$tpl->assign('fckeditor', $fckeditor);//模板賦值
HTML模板頁面(我用的是smarty)
{%$fckeditor%}
一般php頁面調用
content 是我定義的變量名
$content =$_POST["content"];
添加:
<INPUT name="content" id="content" type=hidden>
<IFRAME id="content" src="fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=Normal" frameBorder=0 width=100% scrolling=no height=300 ></IFRAME>
修改頁面:
<INPUT name="content" id="content" type=hidden value="<?php echo $rows['content'];?>">
<IFRAME id="content" src="/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=Normal" frameBorder=0 width=100% scrolling=no height=300 >
</IFRAME>