排行榜 统计
  • 建站日期:2020/07/11
  • 文章总数:151 篇
  • 评论总数:377 条
  • 分类总数:5 个
  • 最后更新:1月17日

实现每评论一次自动排第一功能(Typecho版)

本文阅读 1 分钟
首页 typecho 正文

本文最后更新于2022年12月23日, 已超过461天没有更新。 如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!

下面是主要代码(插入到 functions.php 中):

function Autofirst(){
    $db = Typecho_Db::get();
    $query = $db->select()->from('table.comments')->where('authorId = ?','0')->order('coid',Typecho_Db::SORT_DESC)->limit(100);
    $result = $db->fetchAll($query);
    $arrUrl = array();
    $arrAuthor = array();
    foreach ($result as $value) {
        if($value["url"]!==null){
            array_push($arrUrl,$value["url"]);
            array_push($arrAuthor,$value["author"]);
        }
    }
    $su=array_filter(array_merge(array_unique($arrUrl)));
    $sa=array_filter(array_merge(array_unique($arrAuthor)));
    $num=0;
    for($i=0;$i<count(array_unique($su));$i++){
        if($su[$i]!=="" && $num<16){
            $num+=1;
            $db1 = Typecho_Db::get();
            $query1 = $db1->select()->from('table.comments')->where('url = ?',$su[$i])->order('coid',Typecho_Db::SORT_DESC)->limit(100);
            $result1 = $db1->fetchAll($query1);
            $arrAuthor1 = array();
            foreach ($result1 as $value) {
                    array_push($arrAuthor1,$value["author"]);
            }
            echo '<a href="'.$su[$i].'" rel="external nofollow" class="item col-lg-3 col-md-3 visible-lg visible-md" target="_blank"><i class="glyphicon glyphicon-leaf"></i> '.$arrAuthor1[0].'</a>';
        }
    }
}

调用代码和 css:

此处内容需要评论回复后查看

本文来自投稿,不代表本站立场,如若转载,请注明出处:
-- 展开阅读全文 --
typecho评论显示个性化自定义
« 上一篇 09-28
Typecho评论生成随机用户头像
下一篇 » 09-28
V注册会员 L评论等级
R1 条回复
  1. * * * 🎁 GET FREE iPhone 15: https://orthopaedicum-lich.de/upload/go.php 🎁 * * * hs=6a37d3bb7641be78df7d6387a615b513* :
    2024-02-11     Win 10 /    FireFox

    0o2mz2

没有更多评论了