Tuesday, August 07, 2007

Fixing the Blogger Older Posts Feature Bug

For reasons that are beyond me, when you click on the "Older Posts" link at the bottom of Blogger blogs, instead of taking you to a new page, they load the older posts on the same page. I believe they did this so that the URL of the page stays the same, but it inhibits the back and refresh buttons from working properly. It also screwed up my custom expandable posts so every post on the older pages had a "Read More..." option even when they shouldn't have.

To fix this bug, you can do the following:

1) From Blogger, select the Template tab.
2) Select the Edit HTML link.
3) Check the Expand Widget Templates checkbox.
4) Find the part of the code that starts with
<b:if cond='data:newerPageUrl'>, and replace that "paragraph" and the next one with the following:

<b:if cond='data:newerPageUrl'>
  <span id='blog-pager-newer-link'>
  <a class='blog-pager-newer-link' expr:href='data:newerPageUrl' expr:id='data:widget.instanceId + "_blog-pager-newer-link_JUST_SAY_NO"' expr:title='data:newerPageTitle'><data:newerPageTitle/></a>
  </span>
</b:if>

<b:if cond='data:olderPageUrl'>
  <span id='blog-pager-older-link'>
  <a class='blog-pager-older-link' expr:href='data:olderPageUrl' expr:id='data:widget.instanceId + "_blog-pager-older-link_JUST_SAY_NO"' expr:title='data:olderPageTitle'><data:olderPageTitle/></a>
  </span>
</b:if>


This just adds _JUST_SAY_NO to the end of expr:id='data:widget.instanceId + "_blog-pager-newer-link and expr:id='data:widget.instanceId + "_blog-pager-older-link. You can actually add any text that you want, but "just say no" seemed appropriate to me.

Once you make the change, save the template. The older posts link will now take you to a new page, allowing your back and refresh buttons to work and not screwing up your expandable posts.

2 comments:

cc said...

Thank you, that is just what I needed. Used it on my blog.

Ranjit Mathew said...

Thank you. This resolves the same
issue for my blog as well.

Post a Comment

Note: Only a member of this blog may post a comment.