首页建站帝国CMS教程 帝国CMS分类信息过期时间设置(发布信息选择多久之后显示过期)

帝国CMS分类信息过期时间设置(发布信息选择多久之后显示过期)

 分类信息有效期设置,如下图:第一步:增加字段gqtime  类型选择日期。投稿表单替换html代码(增加字段时请留空)内容修改为:…

 分类信息有效期设置,如下图:

1.gif

第一步:增加字段gqtime  类型选择日期。

投稿表单替换html代码(增加字段时请留空)内容修改为:

 name="gqtime" id="gqtime"> value="<?echo date("Y-m-d",strtotime("+7day")); ?><?=DoReqValue($tbname,'gqtime',stripSlashes($r[gqtime]))?>">7天后过期> value="<?echo date("Y-m-d",strtotime("+1month")); ?><?=DoReqValue($tbname,'gqtime',stripSlashes($r[gqtime]))?>">一个月后过期> value="<?echo date("Y-m-d",strtotime("+3month")); ?><?=DoReqValue($tbname,'gqtime',stripSlashes($r[gqtime]))?>">三个月后过期> value="<?echo date("Y-m-d",strtotime("+6month")); ?><?=DoReqValue($tbname,'gqtime',stripSlashes($r[gqtime]))?>" selected>六个月后过期> value="<?echo date("Y-m-d",strtotime("+20year")); ?><?=DoReqValue($tbname,'gqtime',stripSlashes($r[gqtime]))?>">长期有效>>

 第二步:打开e/class/connect.php文件,找到  //栏目链接。在其上面一行加入如下代码:


//时间
$odate = round(((strtotime($r[gqtime])-strtotime(date('Y-m-d')))/86400),0);
if ($odate>0)
{
$diffTime = ''; //
}
else if ($odate==0)
{
$diffTime = '今天到期 ';
}
else
{
$diffTime = ' class="expire">已过期> ';
}
$listtemp = str_replace ('[!--diffTime--]', $diffTime, $listtemp);

 第三步:信息调用:

列表页调用:[!--diffTime--]

内容页引用JS:

<script language="javascript" src="images/date.js"></script> 

在需要显示的地方调用:

<script>check_tdate('[!--gqtime--]')</script>

  date.js 文件代码如下:


// JavaScript Document
function check_tdate(odate){
var checkArray= new Array() ;
//nowArray = odate.split(" ");
checkArray = odate.split("-");
checkDate = new Date(checkArray[0],checkArray[1],checkArray[2]);

var nowTime = new Date();// 现在时间
var the_year = nowTime.getYear();
var the_month = nowTime.getMonth() + 1;
var the_day = nowTime.getDate();
nowTime = new Date(the_year,the_month,the_day);

var thesecond = 24 * 60 * 60 *1000 ;
var diffTime = (nowTime - checkDate)/thesecond;//计算天数
if (diffTime>0)
{
myreturn ="

"
;
}
else if (diffTime==0)
{
myreturn = '';
}
else
{
diffTime=0-diffTime;
myreturn = '';
}
//alert(myreturn);
document.write(''+myreturn+'')
}

 已过期图片:

1.gif

 

本文来自网络,不代表1号站长-站长学院|资讯交流平台立场。转载请注明出处: https://www.1cn.cc/jianzhan/diguo/22347.html
上一篇帝国CMS本月热点排行的sql条件调用
下一篇 帝国CMS调用最新DIGG顶的最多的文章
admin

作者: admin

这里可以再内容模板定义一些文字和说明,也可以调用对应作者的简介!或者做一些网站的描述之类的文字或者HTML!

为您推荐

评论列表()

    联系我们

    联系我们

    0898-88888888

    在线咨询: QQ交谈

    邮箱: email@wangzhan.com

    工作时间:周一至周五,9:00-17:30,节假日休息

    关注微信
    微信扫一扫关注我们

    微信扫一扫关注我们

    关注微博
    返回顶部