Previous and Next links on posts
Posted by ark, ,
I use blogger to publish this site. my goal was to have a posting ui that wasn't on the site that somebody else looked after that could publish to my own servers. Blogger does this, but it's still lacking in a lot of features and I end up doing a bunch of hacky stuff with php to get it to work how I want. Case in point: it would be nice to have previous and next links at the top or bottom of every post. but blogger doesn't support that. At least not with the 'old' templates, the only ones available if you want to publish to your own site via sftp.

So here you go. goes around your blogger directory and makes little .prevnext files for every php file it finds that there is a previous or next one for. It' a little complicated by the fact you might post more than one post a day. It also makes a calendar in your archives directory called index.html that you can use CSS to style how you want it displayed.

Here is the css I use.

.code {
  overflow:auto; white-space: pre;

.prev {
  float: left;
.next {
 float: right;
.prevnext {
  clear: both;

.archive_calendar {}
.archive_calendar_start {}
.archive_calendar_year {
  color: #B8A80D;
  display: block;
.archive_calendar_month {
  padding-left: 3px;
.archive_calendar_end {
  display: block;
  margin:0px 0px 14px 0px;
.archive_calendar_half_year {
  display: block;

Here is how I include the .prevnext files in my templates

  $pn =  str_replace('.php', '.prevnext', $_SERVER['SCRIPT_FILENAME']);
  if (strpos( $_SERVER['SCRIPT_FILENAME'], 'index.php') === False &&
      file_exists($pn)) {

and I run this from my crontab
1-59/5 * * * * cd /home/blogger/scripts; $HOME/bin/share/ -b /scripts
works o.k. every time I try and play with templates and whatnot, I always feel like redoing the whole thing, but then decide it's a huge waste of time, I should concentrate on getting the info out there rather than prettying it up for the 3 people who might actually read this blog, and most of them read it in an rss reader anyway!


You now have me wondering who the other two readers are.