typecho热门文章统计插件-自己的博客站里添加,需要做模板所以用到,看到老前辈的东西就搬过来了


下载插件:Github 需要科学上网才可以下载,你们想要可以私聊博主哈。

ViewsCounter插件是一款用于统计记录Typecho博客每篇文章浏览次数的Typecho插件,支持设置同一篇文章的多次浏览行为是否计入浏览数量的时间间隔,默认为3600秒,此外还支持获取调用浏览次数最多的文章,并可设置调用的文章数量。

插件安装教程
1、下载插件:[Github][1]

2、解压后,把Typecho-ViewsCounter-master文件夹下的ViewsCounter文件夹上传至usr/plugins/目录

3、登陆自己的typecho网站后台,在控制台——插件中启用名称为“ViewsCounter”的插件

4、启用插件后,点击插件后面的“设置”,进入插件设置界面,插件提供了两项设置,一项是浏览次数最多的文章的调用数量,如果自己没有调用,则忽略;一项是设置同一篇文章同一个人浏览,多久时间内不计算入浏览数量

Typecho文章浏览次数统计插件ViewsCounter


<!--more-->


5、在主题的post.php文件,添加文章浏览次数调用代码:

1
<?php echo ViewsCounter_Plugin::getViews(); ?>
保存即可

扩展:调用浏览量最多的文章
在要调用的位置添加以下代码


<?php foreach (ViewsCounter_Plugin::getMostViewed() as $post): ?>
   <li><a href="<?php echo $post['permalink'] ?>"><?php echo $post['title'] ?></a></li>
<?php endforeach; ?>
循环中支持使用以下字段:

array (size=1)
  0 => 
    array (size=32)
      'cid' => string '5' (length=1)
      'title' => string '文章标题' (length=8)
      'slug' => string '5' (length=1)
      'created' => string '1507556700' (length=10)
      'modified' => string '1512460496' (length=10)
      'text' => string '
                关于串模式匹配算法,相信很多讲解数据结构的书籍都会有讲解,这里先大概提一下。
 
                <!--more-->
 
                ### 串模式匹配算法'(length=102)
      'order' => string '0' (length=1)
      'authorId' => string '1' (length=1)
      'template' => null
      'type' => string 'post' (length=4)
      'status' => string 'publish' (length=7)
      'password' => null
      'commentsNum' => string '0' (length=1)
      'allowComment' => string '1' (length=1)
      'allowPing' => string '1' (length=1)
      'allowFeed' => string '1' (length=1)
      'parent' => string '0' (length=1)
      'views' => string '240' (length=3)
      'categories' => 
        array (size=1)
          0 => 
            array (size=14)
              ...
      'category' => string 'default' (length=7)
      'directory' => 
        array (size=1)
          0 => string 'default' (length=7)
      'date' => 
        object(Typecho_Date)[39]
          public 'timeStamp' => int 1507585500
      'year' => string '2017' (length=4)
      'month' => string '10' (length=2)
      'day' => string '09' (length=2)
      'hidden' => boolean false
      'pathinfo' => string '/archives/5/' (length=12)
      'permalink' => string 'http://127.0.0.1:8001/archives/5/' (length=33)
      'isMarkdown' => boolean true
      'feedUrl' => string 'http://127.0.0.1:8001/feed/archives/5/' (length=38)
      'feedRssUrl' => string 'http://127.0.0.1:8001/feed/rss/archives/5/' (length=42)
      'feedAtomUrl' => string 'http://127.0.0.1:8001/feed/atom/archives/5/' (length=43)

声明:GhostKylin‘S BLOG|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - typecho热门文章统计插件-自己的博客站里添加,需要做模板所以用到,看到老前辈的东西就搬过来了


你好!世界!XladminShell箱子仅供个人学习使用务必遵守《网络安全法》