帝国 CMS 中,要实现 “灵动标签调用的同日信息颜色相同、不同日期颜色不同” 的效果,核心思路是:提取每条信息的发布日期(仅年月日),将日期转换为唯一标识(如哈希值、数值),再根据标识匹配固定颜色组。以下是具体实现方法和示例:
 

[e:loop={35,10,0,0,'','newstime DESC'}]<?

$day=date('Ymd',$bqr[newstime]);

if(!$n){

$n=0;

}

if($bqno==1){

$d=$day;

$class='class=t'.$n.'';

}else{

if($d==$day){

$class='class=t'.$n.'';

}else{

$n++;

$class='class=t'.$n.'';

$d=$day;

}

}

?><a href=<?=$bqsr['titleurl']?> target=_blank <?=$class?>><?=$bqr['title']?>_______[<?=date('Ymd',$bqr[newstime])?>]</a> <br>

[/e:loop]

注意:<?=$class?>为class的css样式

--------------------------------------------------------------------------------------

css样式:

.t0 { color: #DC143C; text-decoration: none; }
.t1 { color: #FF1493; text-decoration: none; }
.t2 { color: #0000FF; text-decoration: none; }
.t3 { color: #008000; text-decoration: none; }
.t4 { color: #FF4500; text-decoration: none; }
.t5 { color: #00FF7F; text-decoration: none; }
.t6 { color: #FFD700; text-decoration: none; }
.t7 { color: #8A2BE2; text-decoration: none; }
.t8 { color: #FF69B4; text-decoration: none; }
.t9 { color: #1E90FF; text-decoration: none; }

  • 系统预设了 10种颜色样式(t0-t9),可根据需要继续添加更多样式

  • 建议 CSS 颜色样式的数量与灵动标签调用的信息条数保持一致,以确保每个日期都有对应的颜色样式

  • 超过预设样式数量的日期将显示为系统默认颜色

一般如果灵动标签调用10条信息就设置10个css颜色,既:10条信息对应10个日期时间