|
安装步骤:
安装前请在根目录下的index.php增加一行
define('ROOT',dirname(__FILE__)."/");
1、下载最新的Smarty,将其中的libs文件夹复制到system/plugins/下,并改名为smarty。
2、下载最新的Fckeditor,将fckeditor文件夹复制到system/plugins/下
3、在system/application/libraries/创建文件:tpl.php增加以下代码:
PHP复制代码 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(BASEPATH .'plugins/smarty/Smarty.class.php');
class Tpl extends Smarty
{
function tpl ()
{
parent ::Smarty();
$this->template_dir = ROOT .'tpl';
$this->compile_dir = ROOT .'cache/tpl_c';
$this->left_delimiter="{"; //定义左边界符
$this->right_delimiter="}"; //定义右边界符
//$this->debugging = true;
}
}
?> 复制代码
4、在system/plugins/目录下增加文件:fckeditor_pi.php 文件,代码如下:
PHP复制代码 <?php
#===========================================================
# Filename: system/plugins/fckeditor_pi.php
# Note : 加配编辑器
# Version : 3.0
# Author : qinggan
# Update : 2009-08-15
#===========================================================
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if (!function_exists('Fckeditor'))
{
function Fckeditor ($var="content",$content="",$toolbar="Default",$width="700px",$height="500px")
{
require_once(BASEPATH ."plugins/fckeditor/fckeditor.php");
$var = $var ? $var : "content";
$fck = new FCKeditor ($var) ;//获得一个变量信息
$sBasePath = $_SERVER['PHP_SELF'] ;
$sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "_samples" ) ) ;
$fck->BasePath = $sBasePath."system/plugins/fckeditor/";
$fck->Value = $content;
$fck->Config['AutoDetectLanguage'] = false;
$fck->Config['DefaultLanguage'] = "zh-cn";
$fck->Config['ToolbarStartExpanded'] = true;
$fck->ToolbarSet = $toolbar != "Default" ? "Basic" : "Default";
$fck->Width = $width ? $width : "543px";
$fck->Height = $height ? $height : "300px";
$fck->Config['EnableXHTML'] = true;
$fck->Config['EnableSourceXHTML'] = true;
return $fck->CreateHtml();
}
}
?> 复制代码
5、自动加载:
修改文件:system/application/config/autoload.php
修改:$autoload['libraries'] = array('tpl'); //如果之前已有新的类,请附加在后面即可。
修改:$autoload['plugin'] = array("fckeditor"); //同上
6、调用方法:
1)、使用Smarty插件
直接在使用
$this->tpl->display("模板.html");
$this->tpl->assign("变量ID","值");
//所有其他用法类似
2)、使用Fckeditor编辑器
直接使用函数
Fckeditor('变量名','值','编辑器类型','宽','高');
例如:
Fckeditor("content","123456789","Default","700px","500px");
可以缩略写成:
Fckeditor("content","123456789");
要附加给模板,使用这样子使用
$this->tpl->assign("editor",Fckeditor("content",""));
以上功能经情感验证成功通过~~~瞄瞄滴,折腾了我好几天了 |
评分
-
查看全部评分
|