DedeCMS 提示信息框美化教程

因为做站的需要,有时用户投稿之后会跳出来一个信息框,DedeCMS官方的信息框很丑,于是就想把官方这个丑东东改了,相关的资料太少了,最后还是自己动手:

需要修改的文件路径:include/common.func.php

升级函数 ShowMsg,修改诉基本思路就是把原来的ShowMSN函数换了。

function ShowMsg($msg,$gourl,$onlymsg=0,$limittime=0,$sname=”提示消息:”)

{

if(empty($GLOBALS[‘cfg_phpurl’])) $GLOBALS[‘cfg_phpurl’] = ‘..’;

$htmlhead = “<html>rn<head>rn<title>”.$sname.” 网站的名字</title>rn<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″ />rn”;

$htmlhead .= “<base target=’_self’/>rn<style>div{line-height:160%;}body{background:url({$GLOBALS[‘cfg_phpurl’]}/img/smg_bg.gif);}</style></head>rn<body leftmargin=’0′ topmargin=’0′>”.(isset($GLOBALS[‘ucsynlogin’]) ? $GLOBALS[‘ucsynlogin’] : ”).”rn<center>rn<script>rn”;

$htmlfoot = “</script>rn</center>rn</body>rn</html>rn”;

$litime = ($limittime==0 ? 1000 : $limittime);

$func = ”;

if($gourl==’-1′)

{

if($limittime==0) $litime = 5000;

$gourl = “javascript:history.go(-1);”;

}

if($gourl==” || $onlymsg==1)

{

$msg = “<script>alert(“”.str_replace(“””,”“”,$msg).””);</script>”;

}

else

{

//当网址为:close::objname 时, 关闭父框架的id=objname元素

if(eregi(‘close::’,$gourl))

{

$tgobj = trim(eregi_replace(‘close::’, ”, $gourl));

$gourl = ‘javascript:;’;

$func .= “window.parent.document.getElementById(‘{$tgobj}’).style.display=’none’;rn”;

}

$func .= ” var pgo=0;

function JumpUrl(){

if(pgo==0){ location=’$gourl’; pgo=1; }

}rn”;

$rmsg = $func;

$rmsg .= “document.write(“<div style=’width:450px;margin-top: 50px;’>”;

$rmsg .= “<div style=’font-size:12px;height: 49px;width: 450px; background:url({$GLOBALS[‘cfg_phpurl’]}/img/wbg.gif);’><span style=’display:block;line-height: 49px; clear: none;float: left;height: 49px;width: 50px;’><a style=’display:block;height: 49px;width: 50px;’ href=’javascript:history.go(-1);’ title=’返回’></a></span><span style=’display: block;clear: none;float: left;height: 20px;width: 400px;font-family: 微软雅黑;font-size: 12px;line-height: 20px;padding-top: 20px;padding-bottom: 9px;text-align: left;’>”.$sname.”</span></div>”);rn”;

$rmsg .= “document.write(“<div style=’display: block; clear: none; float: left; width: 450px; padding-bottom: 9px; background-color: #98e6f9; padding-right: 9px; padding-left: 9px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-right-color: #50a5ba; border-bottom-color: #50a5ba; border-left-color: #50a5ba;’>”);rn”;

$rmsg .= “document.write(“<div style=’display: block; clear: none; float: left; width: 430px; background-color: #FFFFFF; font-size: 12px; line-height: 20px; color: #000000; padding: 15px; font-family: Arial, 宋体;’>”);rn”;

$rmsg .= “document.write(“”.str_replace(“””,”“”,$msg).””);rn”;

$rmsg .= “document.write(“”;

$rmsg .= “</div>”;

if($onlymsg==0)

{

if( $gourl != ‘javascript:;’ && $gourl != ”)

{

$rmsg .= “<div style=’border-top: 1px solid #EEEEEE;display: block; clear: none; float: left; width: 430px; background-color: #F3F3F3; font-size: 12px; line-height: 40px; font-family: Arial, 宋体; text-align: right; height: 40px;’><a href='{$gourl}’><span style=’color: #666666;text-decoration: none;’>如果你的浏览器没反应,请点击这里</span></a> </div>”;

$rmsg .= “</div>”);rn”;

$rmsg .= “setTimeout(‘JumpUrl()’,$litime);”;

}

else

{

$rmsg .= “</div></div>”);rn”;

}

}

else

{

$rmsg .= “</div></div>”);rn”;

}

$msg = $htmlhead.$rmsg.$htmlfoot;

}

echo $msg;

}

修改后的效果图:

1

2

图片:
添加了一背景图片smg_bg.gif 这个大家自己做就行
修改了一个图片wbg.gif 点击下载。

两个图片均在 plus/img/文件夹下
调用:在传参的后面添加一个值,选择加在后面是为了与以前的调用方式兼容。例子:ShowMsg(‘具体内容’,”-1″,0,10000,”信息提示标题:”)。

思章老师

认准了方向,就要勇敢地走下去,十年磨一剑,我相信,只要坚持,一切都有可能。

相关日志

  1. 没有图片

    2011.04.03

    网页设计用到的漂亮字体.备用(更新)

    因为折腾主题和设计网页一直需要与字体打交道,…

  2. 没有图片

    2010.06.18

    WordPress 3.0正式版发布 菠萝筐第一时间升级

    WordPress 3.0正式版发布了,今天…

  3. 没有图片

    2013.12.23

    使用Windows 8.1之系统镜像功能备份恢复系统教程

    新的Windows 8.1系统确实很给力,很…

  4. 没有图片

    2011.04.13

    WordPress不同分类下日志使用不同模板

    这几天把联盟的主题和插件单独设计了一下模板,…

  5. 没有图片

    2010.04.28

    Discuz 7.2 与 Firefox 3.6.X 不兼容解决办法

    当Discuz! 7.2 论坛升级到7.2版…

  6. 没有图片

    2010.05.22

    UCenter info: MySQL Query Error 解决办法之一

    康盛创想的软件越来越庞大,所以出现问题也是正…

评论

  1. 轻风 2009.12.09 11:03上午

    最近正在研究DEDE,煞费脑力~

  2. 俺的趣闻部落格 2009.12.08 5:22下午

    这个貌似Google Chrome的风格。

  3. Louis Han 2009.12.08 1:27下午

    你涉猎还真够广的啊