您现在的位置是:首页 > cms教程 > 帝国CMS教程帝国CMS教程

帝国CMS分类信息发布信息选择多久之后显示过期图标

昕汶2023-04-22帝国CMS教程已有人查阅

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

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

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

第二步:打开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 = '<span class="expire">已过期</span> ';
                 }
        $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 ="<div style='position:absolute;z-index:100;margin-left:150px;'><img src=../../../images/guoqi.gif></div>";
}
else if (diffTime==0)
{
myreturn = '';
}
else
  {
diffTime=0-diffTime;
myreturn = '';
}
//alert(myreturn); 
document.write(''+myreturn+'')
}

已过期图片:

1.gif

本文标签:

很赞哦! ()

相关源码

  • (自适应)电梯扶梯升降梯行业pbootcms企业网站模板(自适应手机版)响应式电梯扶梯类pbootcms模板 电梯生产企业绿色企业网站源码下载PbootCMS内核开发的网站模板,该模板适用于电梯、扶梯类等企业,查看源码
  • (自适应)五金配件机械蓝色营销型pbootcms模板免费下载基于PbootCMS的工业配件展示系统,精简DIV+CSS架构确保响应速度,自适应设计呈现参数表格,支持后台实时更新产品规格、在线留言等内容。查看源码
  • 自适应APP应用程序介绍推广落地页pbootcms网站源码下载移动应用开发商设计的营销型落地页模板,基于PbootCMS内核深度开发采用前沿响应式架构,无缝适配手机端操作习惯与PC端展示需求。查看源码
  • 帝国CMS7.5二次元COS漫展网站模板源码免费下载本模板基于帝国CMS 7.5版本深度开发,为二次元文化分享领域设计。采用UTF-8编码,支持中文内容展示,特别适用于COSPLAY作品展示、漫展信息发布等二次元相关内容的网站建设。模板结构清晰,布局合理,充分考虑了二次元用户群体的浏览习惯和审美需求。查看源码
  • (自适应)水墨风中药馆中医名医介绍pbootcms网站模板本模板基于PbootCMS内核开发,为中医馆、中医药企业量身定制,可快速搭建具有传统文化特色的官方网站。自适应手机端设计,数据实时同步,助您高效展示中医特色诊疗、中药产品、养生知识等内容,塑造专业品牌形象。查看源码
  • (pc+wap)pbootcms网站模板蓝色小程序网站开发公司基于PbootCMS内核开发的营销型门户模板,为小程序开发公司、电商软件企业打造。采用HTML5自适应架构,实现PC与手机端数据实时同步展示查看源码
分享笔记 (共有 篇笔记)
验证码: