- Notifications
You must be signed in to change notification settings - Fork0
jiefei30/VisitorStatistics
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
typecho 博客插件——网站访客量统计
- 代码clone下来之后,将VisitorStatistics文件夹直接放入
/usr/plugins
下 - 进入typecho后台启用插件,在设置中设置初始访问量,默认为0
- 使用方法:
VisitorStatistics_Plugin::getVisitorStatistics();
- 例如,在相应的php页面下加上
<?php echo VisitorStatistics_Plugin::getVisitorStatistics(); ?>
便可输出访客量,如120,622
或者为<?php echo VisitorStatistics_Plugin::getVisitorStatistics('访客量: ',' 次'); ?>
,则输出访客量: 120,622 次
- 修改主题页面文件内容:修改
/usr/themes/handsome/component/sidebar.php
,找到这<ul>
(博客信息 section):在ul里的末尾加上一个li标签:
<liclass="list-group-item text-second"><spanclass="blog-info-icons"><idata-feather="users"></i></span><spanclass="badge pull-right"><?php echo VisitorStatistics_Plugin::getVisitorStatistics(); ?></span><?php _me("访客总数") ?></li>
即:
<ulclass="list-group box-shadow-wrap-normal"><?php Typecho_Widget::widget('Widget_Stat')->to($stat); ?><liclass="list-group-item text-second"><spanclass="blog-info-icons"><idata-feather="award"></i></span><spanclass="badge pull-right"><?php $stat->publishedPostsNum() ?></span><?php _me("文章数目") ?></li><?php if (COMMENT_SYSTEM == 0): ?><liclass="list-group-item text-second"><spanclass="blog-info-icons"><idata-feather="message-circle"></i></span><spanclass="badge pull-right"><?php $stat->publishedCommentsNum() ?></span><?php _me("评论数目") ?></li><?php endif; ?><liclass="list-group-item text-second"><spanclass="blog-info-icons"><idata-feather="calendar"></i></span><spanclass="badge pull-right"><?php echo Utils::getOpenDays(); ?></span><?php _me("运行天数") ?></li><liclass="list-group-item text-second"><spanclass="blog-info-icons"><idata-feather="activity"></i></span><spanclass="badge pull-right"><?php echo Utils::getLatestTime($this); ?></span><?php _me("最后活动") ?></li><liclass="list-group-item text-second"><spanclass="blog-info-icons"><idata-feather="users"></i></span><spanclass="badge pull-right"><?php echo VisitorStatistics_Plugin::getVisitorStatistics(); ?></span><?php _me("访客总数") ?></li></ul>
这里自己还可以 DIY 一些其他信息,图标是 data-feather 这个属性,大家可以去这里替换为其他的