酷秀  - kxiu.cn

typecho调用某个独立页面下面的评论数据

admin的头像admin6个月前教程128热度

例如:有时候需要把动态页面(前提是动态页面功能是通过评论改的)的数据调用在首页,使用下面函数即可。

//调用独立页面信息,$cid为独立页面的cid
function cidshuo($cid){
        $db = Typecho_Db::get();
        $cid = (int) $cid ?? '';
        $comment = $db->fetchAll($db->select()->from('table.comments')
                    ->where('cid = ? AND status = ? AND parent = ?', $cid, 'approved', '0')
                    ->order('coid', Typecho_Db::SORT_DESC)
                    ->limit(1));
        return $comment;
    }

使用方法

echo cidshuo(545);
签名: 最忠诚的BUG开发者来自: 重庆市. Chrome浏览器
文章目录

新年快乐

×
新年快乐
同喜