<?
1
.此处basepath
的路径一定要和上面include的路径一样.否则会找不到文件)
$BasePath
=
"../include/FCKeditor/"
;
include(
$BasePath
.
"fckeditor.php"
);
$fck
= new
FCKeditor
(
'p_info'
) ;//建立对像
$fck
->
BasePath
=
$BasePath
;//Fckeditor所在的位置
$fck
->
ToolbarSet
=
'News'
;//News为自定义的Fckeditor工具栏名称
$fck
->
Width
=
'700'
;//长度
$fck
->
Height
=
'350'
;//高度
$fck
->
Config
[
'AutoDetectLanguage'
] =
false
;//语言
自动检测
$fck
->
Config
[
'DefaultLanguage'
]=
'zh-cn'
;//语言
$content
=
$fck
->
CreateHtml
();//创建Fckeditor脚本文件
$smarty
->
assign
(
'content'
,
$content
);
$smarty
->
display
(
"fck.tpl"
);
?>
在smarty的文件中需要显示的地方
<tr align="left">
<td colspan="2" valign="top" bgcolor="#F5F5F5" class="font12en">
<{$content}>
</td>
</tr>
提取Fckeditor时,采用如下
PHP用$_POST['p_info']得到FCKeditor的值
补充:
另外,对于这个输入内容的变量,如果要把它存入数据库,它的变量名为你建
立对象的名字.例如上面就是
"p_info"
2.
在FCKeditor/_samples/里面有个php调
用的例子.如simples01.php
和sampleposteddata.php这两个.后面那个文件是输出变量名的php
程序,通过这个程序可以得到文本输入框内容的变量名.
3.
配置
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个编辑功能,具体功能如下:
默认的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,等等.完工