• fck与smarty的结合使用


    配置文件

    <?
    $BasePath "../include/FCKeditor/";//定义路径,includes是三级路径
    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的值
    补充:
    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"];
    ?>

  • 相关阅读:
    单例类
    UITableView汇总
    JVM虚拟机——垃圾收集算法
    集合框架 HashMap 的扩容机制, ConcurrnetHashMap 的原理
    java判断两个单链表是否相交
    java中Comparator 和 Comparable的区别
    String getProperty(String key, String def)
    JAVA 单步调试快捷键
    Stanford Word Segmenter使用
    使用ifstream和getline读取文件内容[c++]
  • 原文地址:https://www.cnblogs.com/y0umer/p/2809643.html
Copyright © 2020-2023  润新知