帝国CMS列表页-列表内容字段显示最新24小时文章显示红色日期的简单示例

帝国CMS列表页-列表内容字段显示最新24小时文章显示红色日期

此方法应用在(栏目)列表页或者标签也的列表内容模板,先勾选开启列表内容模板右上角的“使用程序代码”,然后把下列代码放入就行了。具体代码和样式请根据实际情况改变!

$newimg='[!--newstime--]';
if(time()-$r[newstime]<=1*24*3600)
{
        $newimg='<fontcolor=red>[!--newstime--]</font>';
}  
$listtemp='<li><span class=date>'.$newimg.'</span> <a href="[!--titleurl--]" target=_blank>[!--title--]</a> </li>';

或者使用灵动标签

<ul>
[e:loop={'news',15,18,0}]
<?
$newstime=format_datetime($bqr[newstime],'m-d');
if(date('Y-m-d')==date('Y-m-d',$bqr[newstime]))
{
$newstime="<font color=red>$newstime</font>";
}
?>
<li>[<a href="<?=$bqsr[classurl]?>"><?=$bqsr[classname]?></a>]&nbsp;<a href="<?=$bqsr[titleurl]?>"><?=esub($bqr[title],40)?></a><span><?=$newstime?></span></li>
[/e:loop]
</ul>

 

posted @ 2022-03-20 14:42  ninama  阅读(247)  评论(0)    收藏  举报