Friday, September 03, 2004

For Blogger users only: changing your "0 Comments" text

[This post will only be of interest to Blogger users. It is the second in a series of 'Blogger tools' posts; the first was on creating boxed text.]

There's something just a bit painful about turning on Comments on your blog, only to find that Blogger's now shouting Comments (0) at the bottom of all of your carefully composed posts. They might as well just change the text to say "Nobody's reading your blog,so go out and get a life"...

Hence the need for a less self-denigrating way to indicate to the reader(s) that there is/is not reader-supplied commentary available for a particular post.

The following script will make the text say "Comment", "Comment (1)", or "Comments(574)", respectively, if the post has 0, 1 or 574 comments. To use it:


  1. Edit your Settings to turn on comments, if they're not already turned on.
  2. Save your existing template (Copy, Paste, Save As to a textfile somewhere...) in case something goes horribly wrong (yet subtly enough wrong that you went ahead and Saved the "bad" changes I'm about to suggest).
  3. Edit your template:

    1. After the </title> tag (near the top), insert the following lines (Copy them from this webpage and Paste them into your template):
      <script language=javascript>
      <!--
      function myCommentDetailStr(id){
          if (id != '0'){
              if (id == '1'){
                  document.write(" (" + id + ")" );
              } else {
                  document.write("s (" + id + ")" );
              }
          }
      }
      -->
      </script>

    2. Find the "<BlogItemCommentsEnabled>" tag and the corresponding "</BlogItemCommentsEnabled>" tag; replace the text between (but not incuding) these tags with:

      <a class="comment-link" href="<$BlogItemPermalinkURL$>#comments">
      Comment<script>myCommentDetailStr('<$BlogItemCommentCount$>');</script>
      </a>

    3. Preview your weblog to make sure that it looks ok;
    4. If so, Save your template changes
    5. Make a test post, publish it, add some commentary to it to test the script
      (no, your correspondent has not done this thoroughly)




Caveats:
As I said, it hasn't been really tested yet. Apparently one needs to "register" in order to comment; will modify this post when testing has been done.

Also, in the highly unlikely event that someone did comment on this blog back when it had Haloscan-hosted commenting and was not being updated...sorry. I didn't see your comment. It's gone.






1 comment:

Welcome, and thanks for caring enough to donate your time and thoughts toward greater collective wisdom...

Terms of engagement:
* Please be civil.
* * * * Please do not post anonymously * * * (I'd remove this choice if I could, and I may remove your comment if you do) - instead, do this:
Click on the 'Name/URL' radiobutton, then enter your real name (if you're brave) or a pseudonym (if you're not). (You can leave the "URL" field blank.)
Or go ahead and click "Anonymous", but put your name in your comment.

* The Management reserves the right to delete comments (Moderation Certificate can be found here). You can always post it on a blog of your own.

If you run into technical difficulties, please a) accept my apologies, then b) email your comment to aherror2011 at gmail.com with "Comment for [name of this blog]" in the Subject line.

New policy re climate contrarianism comments as of 11/11/2009:
Comments questioning the climate science community's understanding of climate change (97% of active climatologists now believe that the earth is currently warming and that it's human-caused - link) will be deleted unless the commenter:
a) is local
b) uses his real name
c) provides link(s) to substantiate his claim(s)/inference(s)
d) is willing to collaborate on constructing an argument tree, to get us past the usual sterile point-counterpoint-countercounterpoint.
(For people who can't read the above, a summary:
1) Be civil;
2) Don't post w/o giving at least a pseudonym;
3) Don't espouse climate-denial crankery unless you're local and willing to stand behind it.)

Caveats:
1. Comments could be delayed: they are being moderated, and I'm sometimes away from the computer for a day or more.
2. : Perfectly legitimate comments are sometimes miscategorized (by the blogging platform) as spam, & not published. If this happens to yours, please notify me, else I might not notice for a day or two.