Singpolyma

Technical Blog

Last Updated Posts

Posted on

Aditya of The Last Word has made a very useful discovery — the new Blogger RSS feeds are ordered by last update! This means that when you make an edit on an old post, that post is moved to the top of your RSS feed! The use for this immidiately becomes apparent : a widget for showing which posts have been updated recently!

Based off of a quick hack Aditya threw together I have developed some reuseable code to just this end. I have it running asynchronously in my sidebar under the ‘Previous Posts’ heading. When you first load the page (or if you have JavaScript turned off) the normal Blogger-generated ‘Previous Posts’ list is displayed. After the page has loaded, if you have JavaScript on, the list will update to a list of the most recently updated posts.

So, on to the code! There are two versions of this hack : synchronous and asynchronous. If you want it to run synchronously (that is, the page waits for the hack to finish before it continues to render) place the following code where you want the widget to appear:

<script type=”text/javascript” src=”http://jscripts.ning.com/get.php?xn_auth=no&amp;id=1317016;
<script type=”text/javascript”>
//<![CDATA[
do_updated_posts(‘<$BlogURL$>’,”,5);
//]]>
</script>

You can change the 5 to whatever number of posts you want in the list. Save and republish : you’re done!

If you want it to run asynchronously (the page loads before the hack does), insert the following code into your <head> section:

<script type=”text/javascript” src=”http://jscripts.ning.com/get.php?xn_auth=no&amp;id=1317016;
<script type=”text/javascript”>
//<![CDATA[
addLoadEvent(function(){do_updated_posts(‘<$BlogURL$>’,’last_updated_posts’,5);});
//]]>
</script>

Again, you can change the 5 to whatever number of posts you want in the list. Then, insert the following code where you want the list to display:

<div id=”last_updated_posts”><i>Loading…</i></div>

Save and republish. You’re done!

The whole way this works may just be a bug in the rss.xml generating engine. If it is, this hack will stop working when they fix it, since it is dependant on the order of items in rss.xml.

6 Responses

Anonymous

Does this still work? I can’t seem to get it to work on my blog anymore.

Anonymous

This should still work as far as displaying posts, but it may not properly display the last updated posts anymore. This whole hack was based on a bug in the Blogger RSS system which they have likely fixed.

Barry

Hi Sorry to bother but can’t seem to get this one to work, I’ve looked all over for a reason. I have the TOC javascript working, but for some reason this one is giving me trouble.

Any help greatly appreciated.

Stephen Paul Weber

This post is for the old blogger. This hack was further based on a bug in Blogger that is since gone. It no longer works at all.

Leave a Response