Chinaunix首页 | 论坛 | 博客
  • 博客访问: 26267398
  • 博文数量: 2065
  • 博客积分: 10377
  • 博客等级: 上将
  • 技术积分: 21525
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-04 17:50
文章分类

全部博文(2065)

文章存档

2012年(2)

2011年(19)

2010年(1160)

2009年(969)

2008年(153)

分类:

2009-07-25 21:35:01

1.$oFCKeditor->BasePath    = '/My_ECshop/lib/fckeditor/' ;
我的网站根目录是My_ECshop的。
千万不要再出错了!

一份喜悦我的收获:
我在我的项目中利用了Smarty + FCK 来做后台发布新闻的程序。
目前我的做法就是:

前端链接到中央控制器处理----加载FCK并将值赋给FCK的某些变量去---渲染Smarty模型!


具体的可以参考这些个内容 我是转载的

$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的文件中需要显示的地方


<{$content}>


提取Fckeditor时,采用如下
PHP用$_POST['p_info']得到FCKeditor的值
补充:
1.此处basepath的路径一定要和上面include的路径一样.否则会找不到文件)
另外,对于这个输入内容的变量,如果要把它存入数据库,它的变量名为你建
立对象的名字.例如上面就是
"p_info"


我的代码如下:
我的控制器中的一个方法的代码
function showAction(){       
        $title = "hello";
        $contents = "zooo";
        $oFCKeditor = new FCKeditor('content') ;
        $oFCKeditor->BasePath    = '/My_ECshop/lib/fckeditor/' ;
        $oFCKeditor->Value        = $contents ;
        $oFCKeditor->Config['DefaultLanguage'] = 'zh_cn';
        $content = $oFCKeditor->CreateHtml();        //创建Fckeditor脚本文件       
        $this->smary->assign('title',$title);   
        //$array = $this->model->show_info($uid);
        $this->smary->assign('content',$content);   
        $this->smary->display("a.tpl");
    }
加载配置完了FCK的相关功能。请看 BasePath非常重要!
我配置了近一个下午的。要写全目录  即将根目录也要写到位的!

然后的话如果要想在Smarty中引入FCK的话要这样来写的:
$content = $oFCKeditor->CreateHtml();        //创建Fckeditor脚本文件       
        $this->smary->assign('title',$title);   
        //$array = $this->model->show_info($uid);
        $this->smary->assign('content',$content);

而不是说你在Smarty中临时去配置。

好了。后台的东西我是走Smarty的。现在开始要考虑下如何当用户POST数据的时候生成静态页面了!

这个方法我将在下一节中整理出来!

smarty中嵌入网页编辑器

2010-01-14

环境:smarty + fckeditor版本

第一步:看一下fckeditor的配置信息

include("../../fckeditor.php") ;                            //包含进来

?>

真正调用的代码如下:


$sBasePath = $_SERVER['PHP_SELF'] ;

$sBasePath = substr( $sBasePath, 0, strpos($sBasePath, "_samples"));  //  /fckeditor/

$oFCKeditor = new FCKeditor('FCKeditor1') ;                                  //得到自定义的类    

$oFCKeditor->BasePath = $sBasePath ;                                            //定义基本目录

$oFCKeditor->ToolbarSet = "Basic";

$oFCKeditor->Value = '

This is some sample text. You are using FCKeditor.

' ;                    //编辑器里面的值

$oFCKeditor->Create() ;                                                                        //创建编辑器

?>


再来看看如何保存提交过来的数据的

 

if ( isset( $_POST ) )

   $postArray = &$_POST ;                     // 4.1.0 or later, use $_POST

else

   $postArray = &$HTTP_POST_VARS ;  // prior to 4.1.0, use HTTP_POST_VARS

 

foreach ( $postArray as $sForm => $value )

{

       if ( get_magic_quotes_gpc() )

              $postedValue = htmlspecialchars( stripslashes( $value ) ) ;

       else

              $postedValue = htmlspecialchars( $value ) ;

 

?>

                    

                           

                           

                    

}

?>

 

第二步:如何在我们的控制器中将fckeditor配置好就是将其生成。

2.1 将这个内置的编辑器内嵌到系统中

2.2 开始规划好控制器中的代码

视图层的代码如下:

function showmusicedit($result,$id) {

              include(BASEPATH."scripts/libjs/fckeditor/fckeditor.php");        //引入编辑器源码

              $oFCKeditor = new FCKeditor('geci') ;                                   

              $sBasePath  = "/persite/scripts/libjs/fckeditor/";                       //设置好编辑器目录

              $oFCKeditor->BasePath = $sBasePath ;                                   //

              $oFCKeditor->ToolbarSet = "Basic";

              $oFCKeditor->Value = $result[4];

              $oFCKeditor->Config['DefaultLanguage'] = 'zh_cn';

              $geci = $oFCKeditor->CreateHtml();                                       //返回编辑器源码

 

              $this->smary->assign('content',$geci); 

              $this->smary->assign("staticurl",STATICURL);

              $this->smary->assign("siteurl",SITEURL);

              $this->smary->assign("infos",$result);

              $this->smary->assign("id",$id);           

              $this->smary->display('musicedit.tpl');

       }

 

2.3 如何保存这个HTML页面代码的

虽然可以保存为这种HTML格式的代码的。但是好像不能正常加载并显示出来的。

保存的时候不需要加:htmlspecialchars 函数就行了!

此函数的作用:

htmlspecialchars()函数的作用是:转换特殊字符为HTML字符编码。







阅读(993) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~