插件:阅读统计插件.zip

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

<?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)
Last modification:June 27, 2020
如果觉得我的文章对你有用,请随意赞赏