如何在 Typecho 中引入"不蒜子"来统计访问次数
实现效果
- 在访问量数据未取回来之前,统计次数不进行显示
- 在主站点只显示站点总阅读量,以及总访客数
- 在文章处显示站点总阅读量,文章总阅读量,以及总访客数
可直接修改footer.php为如下代码:
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
</div><!-- end .row -->
</div>
</div><!-- end #body -->
<footer id="footer" role="contentinfo">
© <?php echo date('Y'); ?> <a href="<?php $this->options->siteUrl(); ?>"><?php $this->options->title(); ?></a>
<?php _e('Powered by <a href="https://typecho.org">Typecho</a>'); ?><br>
<!-- 不蒜子脚本 -->
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<!-- 不蒜子标签 -->
<?php if($this->is('index')): ?>
<span id="busuanzi_container_site_pv" style='display:none'>
Total reads of this site <span id="busuanzi_value_site_pv"></span> times<br>
</span>
<span id="busuanzi_container_site_uv" style='display:none'>
Visitors of this site <span id="busuanzi_value_site_uv"></span> times<br>
</span>
<?php else: ?>
<span id="busuanzi_container_site_pv" style='display:none'>
Total reads of this site <span id="busuanzi_value_site_pv"></span> times<br>
</span>
<span id="busuanzi_container_page_pv" style='display:none'>
Total reads of this article <span id="busuanzi_value_page_pv"></span> times<br>
</span>
<span id="busuanzi_container_site_uv" style='display:none'>
Visitors of this site <span id="busuanzi_value_site_uv"></span> times<br>
</span>
<?php endif; ?>
</footer><!-- end #footer -->
<?php $this->footer(); ?>
</body>
</html>
原文链接:https://blog.fuyiran.link/Technology/7.html
版权声明:本博客所有文章除特別声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 傅说 (blog.fuyiran.link)