zoukankan      html  css  js  c++  java
  • DedeCms最新文章显示红色日期或加上new字或new小图片

    DedeCMS发布的文章显示红色日期或加上new字或new小图片,给近三天(或当天)发布的文章显示红色日期或加上new字或new小图片等,都是围绕pubdate做文章,写扩展的。

    1、红色的日期

     
    1. [field:pubdate runphp='yes']   
    2. $a="<font color=red>".strftime('%m-%d',@me)."</font>";  
    3. $b=strftime('%m-%d',@me);  
    4. $ntime = time();   
    5. $day3 = 3600 * 24 * 3;  
    6. if(($ntime - @me) < $day3) @me = $a;  
    7. else @me =$b;   
    8. [/field:pubdate] 

    2、红色的(new)

     
    1. [field:pubdate runphp='yes']  
    2. $aa=strftime('%m-%d',@me);  
    3. $ntime = time();  
    4. $tagtime = @me;  
    5. $day3 = 3600 * 24 * 3;  
    6. if($tagtime > $ntime-$day3) @me = "<font color='red'>(new)</font>";  
    7. else @me = $aa;  
    8. [/field:pubdate] 

    3、加new.gif小图片

     
    1. [field:pubdate runphp='yes']  
    2. $aa=strftime('%m-%d',@me);  
    3. $ntime = time();  
    4. $tagtime = @me;  
    5. $day3 = 3600 * 24 * 3;  
    6. if($tagtime > $ntime-$day3) @me = "<img src='new.gif' />".$aa;  
    7. else @me = $aa;  
    8. [/field:pubdate] 

    要注意的问题是:如:"<img src='new.gif' />中不能用双引号,否则不行。

    如果要给当天的高亮显示,把 3600 * 24 * 3 改为 3600 * 24  即可。

    雨田SEOER参考了上面的《DedeCms高亮显示:最新文章显示红色日期或加上new字或new小图片》,但是都是显示在最新文章后面的,而学员要求显示在文章的前面,于是做了适当的修改,亲测效果:

     
    实现了最新发布文章在前面在NEWS图标背景效果。

    此教程,以纳入VIP会员教程中,因为在实际情况用到的比较多。DedeCms高亮显示:最新文章显示红色日期或加上new字或new小图片。

  • 相关阅读:
    前端基础学习分享
    IOS中block和代理
    最近一个项目的反思
    Coreseek Windows下安装调试
    iOS对象属性详解
    我眼里“维多利亚的秘密”中最性感的营销三点式
    用CSS制作带图标的按钮
    简单权限管理设计
    CentOS工作内容(三)配置网络IP地址
    CentOS工作内容(二)关闭SELinux
  • 原文地址:https://www.cnblogs.com/tanlingdangan/p/3800779.html
Copyright © 2011-2022 走看看