在 typecho 后台添加文章、页面阅读统计功能
在数据库添加内容阅读统计字段
ALTER TABLE `typecho_contents` ADD COLUMN `view_count` int(11) UNSIGNED NOT NULL DEFAULT 0;增加文章阅读数函数
更改文件 usr/themes/default/functions.php
// 增加文章阅读数
function add_post_view_count($archive) {
$cid = $archive->cid;
$db = Typecho_Db::get();
$row = $db->fetchRow($db->select('view_count')->from('table.contents')->where('cid = ?', $cid));
$db->query($db->update('table.contents')->rows(array('view_count' => (int) $row['view_count'] + 1))->where('cid = ?', $cid));
}在文章、页面详情页面调用函数
分别修改文件 usr/themes/default/post.php 和 usr/themes/default/page.php,在 $this->need('header.php'); 后面添加调用函数,更改后如下:
<?php
$this->need('header.php');
add_post_view_count($this);
?>
后台文章、页面管理显示阅读数量
更改 var/Widget/Abstract/Contents.php 257行加入 , 'table.contents.view_count' 更改后:
修改页面管理模板 admin/manage-pages.php 加入阅读字段

修改文章管理模板 admin/manage-posts.php 加入阅读字段
