这几天模板修改了,没有过多的检查,今天早上一看Blog,怎么每篇文章的浏览次数没有增加,每天怎么说也有几个人浏览,怎么这个统计没有增加呢?于是跟正常的Blog做了对比,发现原来模板里改的有点问题,修复一下就可以了,修复过程如下:
确保在模板文件夹TEMPLATE下的 default.html,single.html,catalog.html 等页面的头部有如下代码:
头部代码:
<script type="text/javascript">
var strBatchView="";
var strBatchInculde="";
var strBatchCount="";
</script>
尾部代码:
<script type="text/javascript">
$(document).ready(function(){
try{
var elScript = document.createElement("script");
elScript.setAttribute("language", "JavaScript");
elScript.setAttribute("src", "<#ZC_BLOG_HOST#>function/c_html_js.asp?act=batch"+unescape("%26")+"view=" + escape(strBatchView)+unescape("%26")+"inculde=" + escape(strBatchInculde)+unescape("%26")+"count=" + escape(strBatchCount));
document.getElementsByTagName("body")[0].appendChild(elScript);
}
catch(e){};
});
</script>
更新浏览次数代码:
在b_article-single.html模板中,你认为合适的位置加入以下代码(span标签内显示的就是当前文章的浏览次数)。
<span id="spn<#article/id#>"></span>
<script type="text/javascript">strBatchCount+="spn<#article/id#>=<#article/id#>,"</script>
显示浏览次数代码:
在b_article-multi.html模板中,在你认为合适的位置加入以下代码(span标签就是每个文章的浏览次数)。
<span id="spn<#article/id#>"></span>
<script type="text/javascript">strBatchView+="spn<#article/id#>=<#article/id#>,"</script>
