当前位置:首页 > 未命名

zblog调用文章总数、置顶数、tag总数方法大全

8976988823个月前 (01-10)未命名5

在百度看了需要教程之后大概统计下有以下几种方案可行,代码如下;

方案1

function 主题ID_GetCount($total) {    global $zbp;    //文章数量{主题ID_GetCount('article')}    if ($total == 'article')        $s = $zbp->db->sql->Count(        $zbp->table['Post'],        array(array('COUNT', 'log_ID', 'num')),        array(array('=', 'log_Type', 0),  array('=', 'log_Status', 0))    );    //获取总共评论的数量{主题ID_GetCount('comment')}    if ($total == 'comment')        $s = $zbp->db->sql->Count(        $zbp->table['Comment'],        array(array('COUNT', 'comm_ID', 'num')),        array(array('=', 'comm_IsChecking', 0))    );    //获取标签数量{主题ID_GetCount('tag')}    if ($total == 'tag')        $s = $zbp->db->sql->Count(        $zbp->table['Tag'],        array(array('COUNT', 'tag_ID', 'num')),        null    );    //获取置顶数量{主题ID_GetCount('istop')}    if ($total == 'istop')        $s = $zbp->db->sql->Count(        $zbp->table['Post'],        array(array('COUNT', 'log_ID', 'num')),        array(array('=', 'log_Type', 0), array('=', 'log_IsTop', 1),array('=', 'log_Status', 0))    );    $s = GetValueInArrayByCurrent($zbp->db->Query($s), 'num');    return $s;}

除此之外天兴大佬在自己的博客也发布了一些调用统计数量的代码:

方案2

文章总数:{$zbp->cache->all_article_nums}页面总数:{$zbp->cache->all_page_nums}标签总数:{$zbp->cache->all_tags_nums} <!--无效-->浏览总数:{$zbp->cache->all_views_nums} <!--无效-->评论总数:{$zbp->cache->all_comments_nums} <!--无效-->

不知道为什么啊,可能是ZBP版本不同所以标签、浏览、评论我用的时候是无效的。不知道什么原因导致。

还有一种方案也是我目前在用的,代码如下:

方案3

//站点信息function 主题ID_all_views() {    //总访问量    global $zbp;    $all_views = GetValueInArrayByCurrent($zbp->db->Query('SELECT SUM(log_ViewNums) AS num FROM ' . $GLOBALS['table']['Post']), 'num');    return $all_views;}function 主题ID_all_artiles() {    //文章总数    global $zbp;    $all_artiles = GetValueInArrayByCurrent($zbp->db->Query('SELECT COUNT(*) AS num FROM ' . $GLOBALS['table']['Post'] . ' WHERE log_Type=\'0\''), 'num');    return $all_artiles;}function 主题ID_all_comments() {    //评论总数    global $zbp;    $all_comments = $zbp->cache->all_comment_nums;    return $all_comments;}

至于选择使用哪种方案自己决定吧,先收藏再说,免得以后需要时找不着!

扫描二维码推送至手机访问。

版权声明:本文由米表程序发布,如需转载请注明出处。

本文链接:https://www.9909999.xyz/post/321.html

分享给朋友: