smarty中使用fckeditor
网上最常用的做法是先在php中调用fckeditor类的createHtml方法生成一段html,直接assign给一个samrty变量即可
这里我通过smarty的插件机制,可以更方便的在smarty中集成fckeditor,在smarty的plugin目录中新建文件function.fck.php
内容如下
<?php
function smarty_function_fck($params, &$smarty)
{
if(!isset($params['InstanceName']) || empty($params['InstanceName']))
{
$smarty->trigger_error(‘fckeditor: required parameter “InstanceName” missing’);
}
static $base_arguments = array();
static $config_arguments = array();
if(!count($base_arguments))
$init = TRUE;
else
$init = FALSE;
if(isset($params['BasePath']))
{
$base_arguments['BasePath'] = $params['BasePath'];
}
else if(empty($base_arguments['BasePath']))
{
//这里设置默认的fck所在的目录,相对于要使用fck的程序的目录
$base_arguments['BasePath'] = ‘../plugins/fckeditor/’;
}
$base_arguments['InstanceName'] = $params['InstanceName'];
if(isset($params['Value'])) $base_arguments['Value'] = $params['Value'];
if(isset($params['Width'])) $base_arguments['Width'] = $params['Width'];
if(isset($params['Height'])) $base_arguments['Height'] = $params['Height'];
if(isset($params['ToolbarSet'])) $base_arguments['ToolbarSet'] = $params['ToolbarSet'];
if(isset($params['CheckBrowser'])) $base_arguments['CheckBrowser'] = $params['CheckBrowser'];
if(isset($params['DisplayErrors'])) $base_arguments['DisplayErrors'] = $params['DisplayErrors'];
// Use all other parameters for the config array (replace if needed)
$other_arguments [...]
最近评论