首页 > 网站 > 建站经验 > 正文

dedecms如何给内容列表文章添加hot、new小图标?

2024-04-25 20:35:29
字体:
来源:转载
供稿:网友

再用织梦建站的时候,常常需要要在列表页添加前两天的文章后面添加个new小图片,那怎么实现的?B5教程网和你分享一段代码。如下:

红色的日期:

[field:pubdate runphp='yes']

$a="<font color=red>".strftime('%m-%d',@me)."</font>";

$b=strftime('%m-%d',@me);

$ntime = time();

$day3 = 3600 * 24 * 3;

if(($ntime - @me) < $day3) @me = $a;

else @me =$b;

[/field:pubdate]

红色的(new):

[field:pubdate runphp='yes']

$aa=strftime('%m-%d',@me);

$ntime = time();

$tagtime = @me;

$day3 = 3600 * 24 * 3;

if($tagtime > $ntime-$day3) @me = "<font color='red'>(new)</font>";

else @me = $aa;

[/field:pubdate]

加new.gif小图片:

[field:pubdate runphp='yes']

$aa=strftime('%m-%d',@me);

$ntime = time();

$tagtime = @me;

$day3 = 3600 * 24 * 3;

if($tagtime > $ntime-$day3) @me = "<img src='new.gif' />".$aa;

else @me = $aa;

[/field:pubdate]

“hot”添加方法网:

[field:click runphp='yes']

if(@me > 1000 )@me = ”<span class=’hot_ico’></span>”;

else @me = “”;

[/field:click]

这里点击率设定为1000,当“click”大于1000时,添加span标签,然后用CSS将其定位到合适的地方。

 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表