设为首页收藏本站

嘻皮客娱乐学习网

 找回密码
 中文注册
搜索
打印 上一主题 下一主题
开启左侧

[建站知识] php168实现当天新发布的文章日期显示为红色的方法

[复制链接]
跳转到指定楼层
楼主
发表于 2014-10-29 16:27:27 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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}。在修改文件前别忘了先备份一下源文件,养成及时备份的好习惯。
回复

使用道具 举报

小黑屋|手机版|嘻皮客网 ( 京ICP备10218169号|京公网安备11010802013797  

GMT+8, 2024-5-5 13:42 , Processed in 0.166303 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表