dede<php geteditor(,为织梦dedecms不同页面中百度ueditor编辑器设置不同宽度

相信正在使用织梦dedecms作为网站管理程序的站长朋友对织梦自带的ckeditor编辑器***感到***纠心:其难看的外观,不太好用的添加视频功能,超级弱智的图片上传项,就连按个"tab"键都要跳出编辑框...这些无不让我们对其深恶痛绝(可能说得有点夸张)!

本人***近开了一个新站,***初因为这个ckeditor编辑器给编辑工作带来了诸多不便,所以***后痛下决心:改成百度ueditor。

为什么改成ueditor而不是别的编辑器呢?原因主要有三点:

一、ueditor界面相当美观,用起来舒服;

二、功能强悍,比如图片上传功能:它支持批量上传,图片搜索,还有***不错的图片管理器;再比如视频添加功能:直接填写优酷土豆等视频网址即可,不用像ckeditor那样***麻烦地去找".swf"的flash地址;

三、基于百度雄厚的实力,相信这个ueditor功能也会越来越强大。

是不是心动了?

不过ueditor装上后也不是马上就能用的(至于怎么安装,大家可以在官方论坛上找),一般都会存在一些小问题。下面我就来谈谈其中一个***重要的问题的解决方案。

安装完ueditor后,我们可以在ueditor的配置文件中对其界面宽度进行设置,但问题就出在这里,在这里设置的宽度是对全局而言,即所有网站内的编辑器宽度都一样。但对于我们dedecms用户而言,一般前台和后台编辑器宽度不一致,这样就会造成编辑器越界的问题。解决方案:将ueditor宽度设置放在编辑器调用阶段,具体做法如下:

1. /include/helpers/util.helper.php中增加以下代码:

if ( ! function_exists('GetEditorD'))

{

function GetEditorD($fname, $fvalue, $nheight="350", $etype="Basic", $gtype="print", $isfullpage="FALSE",$bbcode=false)

{

if(!function_exists('SpGetEditorD'))

{

require_once(DEDEINC."/inc/inc_fun_funAdmin.php");

}

return SpGetEditorD($fname, $fvalue, $nheight, $etype, $gtype, $isfullpage, $bbcode);

}

}

2. /include/inc/inc_fun_funAdmin.php中增加以下代码:

function SpGetEditorD($fname,$fvalue,$nheight="350",$etype="Basic",$gtype="print",$isfullpage="false",$bbcode=false)

{

global $cfg_ckeditor_initialized;

if(!isset($GLOBALS['cfg_html_editor']))

{

$GLOBALS['cfg_html_editor']='fck';

}

if($gtype=="")

{

$gtype = "print";

}

if($GLOBALS['cfg_html_editor']=='fck')

{

require_once(DEDEINC.'/FCKeditor/fckeditor.php');

$fck = new FCKeditor($fname);

$fck->BasePath = $GLOBALS['cfg_cmspath'].'/include/FCKeditor/' ;

$fck->Width = '100%' ;

$fck->Height = $nheight ;

$fck->ToolbarSet = $etype ;

$fck->Config['FullPage'] = $isfullpage;

if($GLOBALS['cfg_fck_xhtml']=='Y')

{

$fck->Config['EnableXHTML'] = 'true';

$fck->Config['EnableSourceXHTML'] = 'true';

}

$fck->Value = $fvalue ;

if($gtype=="print")

{

$fck->Create();

}

else

{

return $fck->CreateHtml();

}

}

else if($GLOBALS['cfg_html_editor']=='ckeditor')

{

require_once(DEDEINC.'/ckeditor/ckeditor.php');

$CKEditor = new CKEditor();

$CKEditor->basePath = $GLOBALS['cfg_cmspath'].'/include/ckeditor/' ;

$config = $events = array();

$config['extraPlugins'] = 'dedepage,multipic,addon';

if($bbcode)

{

$CKEditor->initialized = true;

$config['extraPlugins'] .= ',bbcode';

$config['fontSize_sizes'] = '30/30%;50/50%;100/100%;120/120%;150/150%;200/200%;300/300%';

$config['disableObjectResizing'] = 'true';

$config['smiley_path'] = $GLOBALS['cfg_cmspath'].'/images/smiley/';

// 获取表情信息

require_once(DEDEDATA.'/smiley.data.php');

$jsscript = array();

foreach($GLOBALS['cfg_smileys'] as $key=>$val)

{

$config['smiley_images'][] = $val[0];

$config['smiley_descriptions'][] = $val[3];

$jsscript[] = '"'.$val[3].'":"'.$key.'"';

}

$jsscript = implode(',', $jsscript);

echo jsscript('CKEDITOR.config.ubb_smiley = {'.$jsscript.'}');

}

$GLOBALS['tools'] = empty($toolbar[$etype])? $GLOBALS['tools'] : $toolbar[$etype] ;

$config['toolbar'] = $GLOBALS['tools'];

$config['height'] = $nheight;

$config['skin'] = 'kama';

$CKEditor->returnOutput = TRUE;

$code = $CKEditor->editor($fname, $fvalue, $config, $events);

if($gtype=="print")

{

echo $code;

}

else

{

return $code;

}

}else if($GLOBALS['cfg_html_editor']=='ueditor')

{

$fvalue = $fvalue=='' ? '

$code = 'script>

script>

'.$fvalue.'

var ue = new baidu.editor.ui.Editor({ initialFrameWidth:824 });ue.render("'.$fname.'"); //红色处为修改宽度

script>';

if($gtype=="print")

{

echo $code;

}

else

{

return $code;

}

}

else {

/*

// ------------------------------------------------------------------------

// 当前版本,暂时取消dedehtml编辑器的支持

// ------------------------------------------------------------------------

require_once(DEDEINC.'/htmledit/dede_editor.php');

$ded = new DedeEditor($fname);

$ded->BasePath = $GLOBALS['cfg_cmspath'].'/include/htmledit/' ;

$ded->Width = '100%' ;

$ded->Height = $nheight ;

$ded->ToolbarSet = strtolower($etype);

$ded->Value = $fvalue ;

if($gtype=="print")

{

$ded->Create();

}

else

{

return $ded->CreateHtml();

}

*/

}

}

3. 在编辑器调取页面将以下代码:

改为:

以上方案的思想是:在不同界面使用不同的编辑器调用函数。

当然你可以根据需要对以上代码进行删改。

DedeCMS问题解决

请点击在线联系我们【点击咨询解决问题】   如果您有任何织梦问题,我们将免费为您写解决教程!

用心认真写教程不易,请小打赏我们一下,多少是心意,解决问题是重点

【打赏说明】 如果您认为在本站中看的内容质量不错、或阅读后有所收获、或解决您遇到的实际问题,那不妨小金额的赞助一下尚禹科技,让尚禹科技有动力继续写出更多高质量的教程和心得。以帮助更多的人。[查看打赏记录]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值