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 随机色 宏定义
    linux下自定义pid实现任意数据采集
    http://blog.chinaunix.net/uid-9845710-id-1996675.html snmpd配置
    http://www.360doc.com/content/10/0928/12/11991_57014502.shtml
    pingall脚本
    http://lihuipeng.blog.51cto.com/3064864/643960
    elf 文件
    php中获取周几的方法
  • 原文地址:https://www.cnblogs.com/onlylove2015/p/4393656.html
Copyright © 2011-2022 走看看