Battling Blogger Blues

Introduction

Sometimes Blogger has it's own idea as to what a blog is and what it should and shouldn't do.  If you want what it wants, every thing is hunky dory.  On the other hand, if you have different notion than Blogger, then be prepared for battle.

Skirmish 1:  The posts are all in the wrong order.

When we were on our pilgrimage, it made sense to have the most recent post at the top, so our adoring fans could follow our progress.  However, now that our walk is done, it makes much more sense to present newcomers the posts in chronological order, with the oldest posts first; our posts build on each other so reading them in order works best.  Since Blogger disagrees, there is no such option.  Fortunately (or tragically as the case may be), one can add html and javascript to Blogger to encourage better behavior.

An  Easy Way

Blogger graciously places all of the posts entries on the home page in as children of a <div> in the "hfeed" class, so we can write a bit-o-javascript to find all the entries, and reverse them:

<script>
function flip_entries() {
   var posts = document.getElementsByClassName("hfeed")[0]
   var count = posts.childNodes.length;
   while (count--)
     posts.appendChild(posts.childNodes[count]);
  }
</script>

This works because posts is a "live" object, so the append moves each entry to a new position.  We then add a button to call our post flipper, and let our fans choose the order.

<button style="display:inline" onclick="flip_entries()">
  Reverse Blog Entries
</button>

We can tell Blogger to show all of our post summaries on the main page at once, and we should be good to go.  Easy, just edit the Blog Posts widget and tell it to show 10,000 posts on the main page, which should be all of the posts: hitting the "Reverse Blog Entries" button should get us our oldest post at the top of the page.

Not so Fast

Sadly, since Blogger knows better than you, it ignores the max posts number once the main page is "too big", so you only get to reverse a subset of posts, which kind of defeats the intended purpose.

Next: Bringing out the Big Guns




Comments