php168实现当天新发布的文章日期显示为红色的方法
很多朋友想实现当天新发布的文章日期显示为红色这样一个功能,在网上搜索了很长时间,终于找到了解决方法,实例请看本站首页,方法如下:
1、打开网站根目录/inc/label_funcation.php文件,找到其中的这段代码
function Get_Title($format){
global $db,$webdb,$pre;
//此处屏障报错,主要是处理不同版本之间存在的一些差异性问题
$query=$db->query("$format[sql]",'','0');
if(!$query){
return ;
}
while($rs=$db->fetch_array($query)){
$rs=++$i;
if($format[wninfo]&&$rs[mid]){
$_rss=$db->get_one("SELECT * FROM {$pre}{$format[wninfo]}content_{$rs[mid]} WHERE id='$rs[id]' LIMIT 1");
$rs=$rs+$_rss;
}
$rs[full_time]=$rs[posttime];
$rs[full_title]=$rs[title];
//内容
$rs[content]=preg_replace('/<([^>]*)>/is',"",$rs[content]); //把HTML代码过滤掉
$rs[content]=get_word($rs[content],$format[content_num]);
//标题
$rs[title]=get_word($rs[title],$format[titlenum],$format[titleflood]);
在下面插入这段代码
if ($rs[posttime]>=time()-86400&&$webdb[hotArticleNum]&&$rs['hits']<=$webdb[hotArticleNum]){
$rs[titlecolor]="";
$rs[titlecolorn]="";
}
else{
$rs[titlecolor]="";
$rs[titlecolorn]="";
}
然后在模板页面想要显示日期的地方插入以下代码就可以了,{$titlecolor}$posttime{$titlecolorn}。在修改文件前别忘了先备份一下源文件,养成及时备份的好习惯。 |