fck与smarty的结合使用

配置文件

<?
$BasePath="../include/FCKeditor/";//定义路径,includes是三级路径
include($BasePath."fckeditor.php");

$fck= newFCKeditor('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的值
补充:
1.此处basepath的路径一定要和上面include的路径一样.否则会找不到文件)
另外,对于这个输入内容的变量,如果要把它存入数据库,它的变量名为你建
立对象的名字.例如上面就是
"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。

-------合体配置

一、在Smarty中调用FCKeditor的文件:
<?php
require_once("class/Smarty.class.php");
require_once('FCKeditor/fckeditor.php'); //导入FCKeditor

/*实例并初始FCKeditor*/
$editor = new FCKeditor("content") ; //接收时$_POST['...']中的内容
$editor->BasePath = "../FCKeditor/"; //FCKEDITOR的路径
$editor->ToolbarSet = "Basic";
$editor->Value = "";
$FCKeditor = $editor->CreateHtml(); //创建编辑器,为HTML结果代码

/*实例并初始Smarty*/
$smarty = new Smarty();
$smarty->template_dir = "../templates";
$smarty->compile_dir = "../templates_c";
$smarty->left_delimiter = "<{";
$smarty->right_delimiter = "}>";
$smarty->assign('Title',"Rossy is here waiting for you");
$smarty->assign('FCKeditor',$FCKeditor); //替换FCKeditor 标签
$smarty->display('template.tpl');
?>

二、template.tpl
<htm>
<head>
<title>example of smarty use fckeditor</title>
</head>
<body>
<P>Example</p>
<p>title:<{$Title}></p>
<p></p>
<p>content:</p>
<p><{$FCKeditor}></p>
</body>
</html>

三、获取FCKeditor传递值 getValue.php
<?php
echo $_POST["content"];
?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值