优选主流主机商
任何主机均需规范使用

如何根据留言数量自动显示不同欢迎语以此提升互动体验

如还没人留言就显示“Add comments”,只有一条留言显示“1 comment” ,多条留言显示“n comments”;然后在CSS中定义.post-comment就可以了(当然你也可以改成其它)。可用于b_article-multi.html 摘要文章模板,b_article-istop.html 置顶文章模板,b_article-single.html 日志页文章模板这几个模板文件中。

1. 英文显示版

  1. <span class=”post-comment”>
  2. <a id=”p_comments<#article/id#>” href=”<#article/url#>#comments”><#article/commnums#> comments</a>
  3. <script type=”text/javascript”>if(<#article/commnums#>==0)
  4. {document.getElementById(“p_comments<#article/id#>”).innerHTML=”Add comments”};
  5. if(<#article/commnums#>==1)
  6. {document.getElementById(“p_comments<#article/id#>”).innerHTML=”1 comment”}</script>
  7. </span>

2. 中文显示版

  1. <span class=”post-comment”>
  2. <a id=”p_comments<#article/id#>” href=”<#article/url#>#comments”><#article/commnums#> 条评论了</a>
  3. <script type=”text/javascript”>if(<#article/commnums#>==0)
  4. {document.getElementById(“p_comments<#article/id#>”).innerHTML=”发表评论”}</script>
  5. </span>

 

未经允许不得转载:搬瓦工中文网 » 如何根据留言数量自动显示不同欢迎语以此提升互动体验