Blogger Pagination Hack
So. I wrote a pagination hack for my blog yesterday. For the uninitiated, pagination refers to the links on a site that go something like "newer posts" and "older posts". Here are some instructions for anyone interested in using it.
1) Download
this. If you run a puny OS like Windows you can unzip it using
WinRAR.
2) Navigate to your Blogger Settings page, Formatting tab. Change the "Timestamp format" to the one that says something like "6/22/2007 01:33:55 PM".
3) Host the files somewhere and include them in your blog template. If you do not know how to do that, you can copy and paste the following code. It must be somewhere between your <head> and </head> tags.
<!-- pagination hack includes -->
<link rel="stylesheet" type="text/css" href="http://trashb.in/css/bloggerpaginationhack.css" />
<script src="http://trashb.in/js/bloggerpaginationhack.js"></script>
<!-- end pagination hack -->
You can, of course, choose to omit the comments, but they do make it easier to find and modify/remove code.
4) You also need to include the following javascript variables, again, in your HTML header.
<!-- pagination hack variables -->
<script type="text/javascript">
var datestr="";
var page=0;
</script>
<!-- end pagination hack -->
5) Include the following code somewhere within where your post is displayed. Placing it somewhere near your permalink would probably work fine. This updates the variable that stores the date of the earliest post on the current page.
<!-- pagination hack updating variables -->
<script type="text/javascript">
datestr = "<$BlogItemDateTime$>";</script>
<!-- end pagination hack -->
6) Finally, include the following at the bottom of your page.
<!-- pagination hack write newer and older posts links -->
<div id="moreposts">
<span id="new"><a id="newer" href=""><< Newer posts</a></span>
<span id="old"><a href="" id="older">Older posts >></a></span>
<script type="text/javascript">
getParams(datestr);
</script>
</div>
It is a crude hack, because I'm not really a javascript hacker, and there is one major imperfection in that the "newer posts" link is really just a back button. I did it that way because apparently the query parameter "updated-min" does not work the way I would expect it to work. However,
this guy apparently managed to work it. I had no time to find out how, but if anyone can tell me, I'd be much obliged.
p.s. If you happen to use this code, please post a link to this post or post a comment here telling me I'm cool so that I can know how many people are using it and thereby validate my own existence, k thx.
Labels: blogger, geek, hack, pagination