您现在的位置是:首页 > cms教程 > 帝国CMS教程帝国CMS教程
帝国CMS分类信息发布信息选择多久之后显示过期图标
昕汶2023-04-22 22:41:51帝国CMS教程已有人查阅
导读分类信息有效期设置,如图:第一步:增加字段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+'')
}
已过期图片:
本文标签:
很赞哦! ()
相关文章
随机图文
帝国CMS调用栏目下所对应专题的方法
问:有若干个专题,所属一个栏目,那在栏目模板中如何自动调用这些专题名?能否象调用子栏目一样。帝国CMS播放地址/下载地址按钮错位怎么办
有的模板再做下载按钮或者播放按钮列表发现如下错位了,该如何解决呢?方法除了在栏目管理的选项里面进行如下修改,其实还有另外一种彻底解决的方法!进行如下修复就可以彻底解决了帝国CMS截取简介函数过滤特殊字符及空格的方法
帝国cms内容页模板的描述标签,是直接输出内容标题,这个在seo优化当中还是有一定影响的,新闻在发布时会自动生成smalltext简介字段,但我们如果直接在页面上输出简介字段帝国CMS灵动标签SQL调用多条广告的方法
这个方法并不是很实用,因为不如JS直接调用来的方便,但是用在一些特殊需求里是可以的,写以下代码留待有需要的小伙伴参考!
留言与评论 (共有 条评论) |