关于ZBlog如何显示文章的浏览次数
浏览: 发表时间:2011-12-27 来源: 保定龙跃网络【返回】
关于ZBlog如何显示文章的浏览次数
在 TEMPLATE\ default.html,single.html,catalog.html 等页面的头部和尾部(指<body ></ body>内)分别加上如下代码:
头部代码:
<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>
1、更新浏览计数
然后在b_article-single.html模板中,你认为合适的位置加入以下代码,<span>标签内显示的就是当前文章的浏览次数。
<span id="spn<#article/id#>"></span>
<script type="text/javascript">strBatchCount+="spn<#article/id#>=<#article/id#>,"</script>
2、显示浏览计数
修改b_article-multi.html模板,在你认为合适的位置加入以下代码,span标签就是每个文章的浏览次数。
<span id="spn<#article/id#>"></span>
<script type="text/javascript">strBatchView+="spn<#article/id#>=<#article/id#>,"</script>

