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小图片。

  • 相关阅读:
    OTPUB知识课堂——VMware虚拟机应该如何优化
    春风十里,不如梭子鱼云安全解决方案全心为你!
    企业进行云存储,必须先搞清楚这5个问题
    OTPUB知识讲堂——如何在云计算中部署SQL
    Convertlab——营销的艺术,数字化的艺术
    腾讯云化解安全危机,开启网络安全智能时代
    11.2
    笔记
    this
    JS数据的基本类型
  • 原文地址:https://www.cnblogs.com/tanlingdangan/p/3800779.html
Copyright © 2011-2022 走看看