Smarty中调用FCKeditor的方法


Posted in PHP onOctober 27, 2014

本文实例讲述了Smarty中调用FCKeditor的方法,分享给大家供大家参考。具体实现方法如下:

FCKeditor是目前互联网上最好的在线编辑器。

smarty是一个使用PHP写出来的模板PHP模板引擎,它提供了逻辑与外在内容的分离,简单的讲,目的就是要使用PHP程序员同美工分离,使用的程序 员改变程序的逻辑内容不会影响到美工的页面设计,美工重新修改页面不会影响到程序的程序逻辑,这在多人合作的项目中显的尤为重要。

在Smarty中调用FCKeditor的文件:

require_once("conn.php");  

require_once("class/Smarty.class.php");  

  

$smarty = new Smarty();  

$smarty->template_dir = "../templates";  

$smarty->compile_dir  = "../templates_c";  

$smarty->left_delimiter = "<{";  

$smarty->right_delimiter = "}>";  

  

$editor = new FCKeditor("Content") ;  

$editor->BasePath   = "../FCKeditor/";  

$editor->ToolbarSet = "Basic";  

$editor->Value      = "";  

$FCKeditor = $editor->CreateHtml();  

  

$smarty->assign('Title',"Rossy is here waiting for you");  

$smarty->assign('FCKeditor',$FCKeditor);    

$smarty->display('template.tpl');

但是运用这一种方法在编辑资料的时候竟然FCKeditor传不了值,只是生成了一个空值的编辑器,所以只能换一种方法:

require_once("conn.php");  

require_once("class/Smarty.class.php");  

   

$smarty = new Smarty();  

$smarty->template_dir = "../templates";  

$smarty->compile_dir  = "../templates_c";  

$smarty->left_delimiter = "<{";  

$smarty->right_delimiter = "}>";  

  

$editor = new FCKeditor("Content") ;  

$editor->BasePath   = "../FCKeditor/";  

$editor->ToolbarSet = "Basic";  

$editor->Value      = "Here is a example of smarty and FCKeditor";  

  

$smarty->assign('Title',"Rossy is here waiting for you");  

$smartyl->assign_by_ref("FCKeditor",$editor);  

$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>

希望本文所述对大家的PHP程序设计有所帮助。

PHP 相关文章推荐
一个简单的域名注册情况查询程序
Oct 09 PHP
phpMyAdmin 安装及问题总结
May 28 PHP
PHP及Zend Engine的线程安全模型分析
Nov 10 PHP
浅谈php中mysql与mysqli的区别分析
Jun 10 PHP
ThinkPHP中处理表单中的注意事项
Nov 22 PHP
PHP常用的小程序代码段
Nov 14 PHP
PHP+Jquery与ajax相结合实现下拉淡出瀑布流效果【无需插件】
May 06 PHP
PHP中explode函数和split函数的区别小结
Aug 24 PHP
php封装的表单验证类完整实例
Oct 19 PHP
Yii2压缩PHP中模板代码的输出问题
Aug 28 PHP
浅谈PHP SHA1withRSA加密生成签名及验签
Mar 18 PHP
Thinkphp5.0框架视图view的模板布局用法分析
Oct 12 PHP
smarty简单分页的实现方法
Oct 27 #PHP
smarty半小时快速上手入门教程
Oct 27 #PHP
php命令行用法入门实例教程
Oct 27 #PHP
php基于mcrypt的加密解密实例
Oct 27 #PHP
CI框架学习笔记(二) -入口文件index.php
Oct 27 #PHP
PHP改进计算字符串相似度的函数similar_text()、levenshtein()
Oct 27 #PHP
CI框架学习笔记(一) - 环境安装、基本术语和框架流程
Oct 26 #PHP
You might like
小偷PHP+Html+缓存
2006/11/25 PHP
php smarty的预保留变量总结
2008/12/04 PHP
解决laravel5中auth用户登录其他页面获取不到登录信息的问题
2019/10/08 PHP
浅析用prototype定义自己的方法
2013/11/14 Javascript
微信JSSDK上传图片
2015/08/23 Javascript
jQuery多级联动下拉插件chained用法示例
2016/08/20 Javascript
D3.js封装文本实现自动换行和旋转平移等功能
2016/10/14 Javascript
jQuery 遍历map()方法详解
2016/11/04 Javascript
深入理解Vue官方文档梳理之全局API
2017/11/22 Javascript
微信小程序使用slider设置数据值及switch开关组件功能【附源码下载】
2017/12/09 Javascript
javascript实现QQ空间相册展示源码
2017/12/12 Javascript
jQuery实现表单动态添加数据并提交的方法
2018/07/19 jQuery
微信小程序使用npm支持踩坑
2018/11/07 Javascript
Angular脚手架开发的实现步骤
2019/04/09 Javascript
搭建一个Koa后端项目脚手架的方法步骤
2019/05/30 Javascript
Vue仿微信app页面跳转动画效果
2019/08/21 Javascript
vue实现公告栏文字上下滚动效果的示例代码
2020/06/16 Javascript
jQuery 实现DOM元素拖拽交换位置的实例代码
2020/07/14 jQuery
ES6学习教程之Promise用法详解
2020/11/22 Javascript
利用Vue实现简易播放器的完整代码
2020/12/30 Vue.js
[05:07]DOTA2英雄梦之声_第14期_暗影恶魔
2014/06/20 DOTA
[00:12]2018DOTA2亚洲邀请赛 Sccc亮相SOLO赛,今年他又会有什么样的战绩?
2018/04/06 DOTA
在Python中使用异步Socket编程性能测试
2014/06/25 Python
Python psutil模块简单使用实例
2015/04/28 Python
python使用selenium实现批量文件下载
2019/03/11 Python
windows下安装Python虚拟环境virtualenvwrapper-win
2019/06/14 Python
python中字符串数组逆序排列方法总结
2019/06/23 Python
python爬虫开发之selenium模块详细使用方法与实例全解
2020/03/09 Python
python实现FTP文件传输的方法(服务器端和客户端)
2020/03/20 Python
python 元组的使用方法
2020/06/09 Python
工作室成员个人发展规划范文
2014/01/24 职场文书
关于梦想的演讲稿
2014/05/05 职场文书
关于保护环境的标语
2014/06/09 职场文书
2014年小学图书室工作总结
2014/12/09 职场文书
出纳2015年度工作总结范文
2015/10/14 职场文书
Python可视化神器pyecharts之绘制箱形图
2022/07/07 Python