emlog博客自己没有添加标签这个功能,下面我来给各位同学介绍emlog后台添加标签统计与网站统计的方法,有需要了解的同学可进入参考.
标签统计就是统计有多少个标签
1、修改include/lib/cache.php文件中的站点统计,添加标签统计缓存,大概在126-147行,代码如下:
- private function mc_sta() {
- $sta_cache = array();
- $lognum = $this->db->num_rows($this->db->query("SELECT gid FROM " . DB_PREFIX . "blog WHERE type='blog' and hide='n' "));
- $draftnum = $this->db->num_rows($this->db->query("SELECT gid FROM " . DB_PREFIX . "blog WHERE type='blog' and hide='y'"));
- $comnum = $this->db->num_rows($this->db->query("SELECT cid FROM " . DB_PREFIX . "comment WHERE hide='n' "));
- $hidecom = $this->db->num_rows($this->db->query("SELECT gid FROM " . DB_PREFIX . "comment where hide='y' "));
- $tbnum = $this->db->num_rows($this->db->query("SELECT gid FROM " . DB_PREFIX . "trackback "));
- $twnum = $this->db->num_rows($this->db->query("SELECT id FROM " . DB_PREFIX . "twitter "));
- $tagnum = $this->db->num_rows($this->db->query("SELECT tid FROM " . DB_PREFIX . "tag"));//统计标签条数
- $sta_cache = array( //开源软件:Vevb.com
- 'lognum' => $lognum,
- 'draftnum' => $draftnum,
- 'comnum' => $comnum,
- 'comnum_all' => $comnum + $hidecom,
- 'twnum' => $twnum,
- 'hidecomnum' => $hidecom,
- 'tbnum' => $tbnum,
- 'tagnum' => $tagnum
- );
2、修改后台信息页admin/views/index.php,大概在21行.
- <li>有<b><?php echo $sta_cache['lognum'];?></b>篇日志,<b><?php echo $sta_cache['comnum_all'];?></b>条评论,<b><?php echo $sta_cache['twnum'];?></b>条碎语, <b><?php echo $sta_cache['tagnum'];?></b>个标签</li>
因为emlog5.1.0beta中,日志改为文章了,所以上面的代码也可以把日志改为文章.
Emlog博客添加站点统计
很简单,在需要显示的位置对应的模板部分加上如下代码:
- 日志数量:<?php echo $sta_cache['lognum'];?>
- 评论数量:<?php echo $sta_cache['comnum_all'];?>
- 碎语数量:<?php echo $sta_cache['twnum'];?>
- 建站日期:2012-11-25
- 运行时间:<?php echo floor((time()-strtotime("2012-12-05"))/86400); ?>
李明选择在侧边栏显示站点统计,把以下代码添加到模板文件(side.php)对应位置可以了,代码如下:
- <div style="border: 1px solid #BBD7E6;padding:5px;margin:10px 0px 10px 0px;background-color:#F7F4ED;" align="left">
- <li>日志数量:<?php echo $sta_cache['lognum'];?></li>
- <li>评论数量:<?php echo $sta_cache['comnum_all'];?></li>
- <li>碎语数量:<?php echo $sta_cache['twnum'];?></li>
- <li>建站日期:2012-11-25</li>
- <li>运行时间:<?php echo floor((time()-strtotime("2012-12-05"))/86400); ?></li>
- </div>
这是全站显示的,只在首页显示就要加上以下首页判断代码:
- <?php if("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] == BLOG_URL):?>
- //加上你的代码
- <?php endif;?>
新闻热点
疑难解答