Farrago recent comments hack [eng]

Home » Tutorials for Blogging » Farrago recent comments hack [eng]

One thing that most of people miss on blogger is a list of the recent comments.
So searching around the web I found this simple script, I tested and I can say that it works very well!
So here you can find instructions to install this script that I lightly modified to make it work in the right way on my templates:

Thanks for the script and guide to : BloggerHack

Change comment date settings!

Go the the Comments section of your blog Settings and make sure that the Comments Timestamp Format is set to mm/dd/yyyy hh:mm:ss (02/11/2005 8:37:08 PM). Save any changes.

If you don’t use this particular timestamp format the hack won’t be able to compare the dates of the different comments to determine which was posted more recently.

Install the Farrago Recent Comments Hack

Edit your blogger template and find the section of the sidebar where it displays the recent posts. It should look something like this:

<div class=“boxmenu”>
                                          
<div class=“voicemenu”>
                               
   Previous entries
                     
</div>
                                                              
<ul>
<bloggerpreviousitems><li>
<a href=“<$BlogItemPermalinkURL$>"><$BlogPreviousItemTitle$></a>
</li></bloggerpreviousitems>
</ul>   

</div>

Just after this code copy and paste this code:


<!-- **** FARRAGO RECENT COMMENTS HACK **** -->
<!-- Version 1.03 -->
<!-- Copyright © 2004 Ebenezer Orthodoxy -->
<!-- http://boggerhacks.blogspot.com -->
<!-- Modified version by Cristina for Pannasmontata Templates -->
<!-- http://pannasmontata-templates.net -->
<!-- ************** OPTIONS *************** -->

<script type="text/javascript" language="JavaScript1.2">
var titleText = "Recent Comments";
var numberToShow = 5;
var displayTemplate = "[name] in [title]";
var nameIsLink = true;
</script>
<!-- ********* CODE DO NOT CHANGE ******** -->
<script type="text/javascript" language="JavaScript1.2">
var comments=new Array(0);var title = "";
var itemurl = "";
function getSortDate(strDate){var d=new Date(strDate);
var day=''+d.getDate();if(day.length==1)day='0'+day;
var month=''+(d.getMonth()+1);if(month.length==1)
month='0'+month;var hour=''+d.getHours();
if(hour.length==1)hour='0'+hour;var min=''+
d.getMinutes();if(min.length==1)min='0'+min;var sec=''+
d.getSeconds();if(sec.length==1)sec= '0'+sec;
var sortDate=''+d.getFullYear()+month+day+hour+min+sec;
return sortDate;}
function recentComment(t,u,i,a,d){var rcmnt=
document.getElementById('frch'+i).innerHTML;
while(rcmnt.indexOf("\n") > -1)rcmnt=
rcmnt.replace("\n","");while(rcmnt.indexOf(" />") > -1)
rcmnt=rcmnt.replace(" />","/>");
while(rcmnt.indexOf(" <a/>") > -1)rcmnt=
rcmnt.replace(" <a/>","<a/>");var author=a;var pos=
rcmnt.toLowerCase().lastIndexOf('<br><a></a>posted by');
var pos2=
rcmnt.toLowerCase().lastIndexOf('<br><a></a><a></a>');
var pos3=
rcmnt.toLowerCase().lastIndexOf('<br/><a/><a/>');
var pos4=
rcmnt.toLowerCase().lastIndexOf('<br/><a></a><a></a>');
var aoffset=pos+6;if (pos3 > -1) pos2=pos3;
if (pos4 > -1) pos2=pos4;
if (pos2 > -1){pos=pos2;aoffset=
rcmnt.toLowerCase().lastIndexOf('<a><b> </b></a>');
if (aoffset==-1)aoffset=
rcmnt.toLowerCase().lastIndexOf('<a><b></b></a>')-1;}
if (pos > -1){author=
rcmnt.substr(aoffset+15,rcmnt.length-1);var expt="";
expt=rcmnt.substr(0,pos-4).replace(/(<([^>]+)>)/ig,"");}
else expt=rcmnt.replace(/(<([^>]+)>)/ig,"");
author=author.replace("<A ","<a ");
if (expt.length > 50){expt=expt.substr(0,50);
if (expt.lastIndexOf(' ') > -1)
expt=expt.substr(0,expt.lastIndexOf(' '));expt+='...';}
expt=expt.replace('"',"\"");expt=expt.replace("'","\'");
if (!nameIsLink)author=author.replace(/(<([^>]+)>)/ig,"");
var st=getSortDate(d)+'<li>'+displayTemplate+'</li>';
st=st.replace('[name]',author);
st=st.replace('[title]','<a title="'+expt+'" href="'+
u+'#c'+i+'">'+t+'</a>');comments.push(st);}</script>

<div class="boxmenu">


<MainPage><div class="voicemenu">
<script type="text/javascript" language="JavaScript1.2">
document.write(titleText+'</div>');</script>
<Blogger>
<span id="frcht<$BlogItemNumber$>"
style="visibility:hidden;position:absolute;">
<BlogItemTitle><$BlogItemTitle$></BlogItemTitle></span>
<script type="text/javascript" language="JavaScript1.2">
title=
document.getElementById('frcht<$BlogItemNumber$>').innerHTML;
itemurl='<$BlogItemPermalinkURL$>';</script>
<BlogItemCommentsEnabled><BlogItemComments>
<span id="frch<$BlogCommentNumber$>"
style="visibility:hidden;position:absolute;">
<$BlogCommentBody$></span>
<script type="text/javascript" language="JavaScript1.2">
recentComment(title,itemurl,'<$BlogCommentNumber$>',
'<$BlogCommentAuthor$>','<$BlogCommentDateTime$>');
</script></BlogItemComments>
</BlogItemCommentsEnabled></Blogger><ul>
<script type="text/javascript" language="JavaScript1.2">
comments.sort();comments.reverse();
for (i=0; i<10 && i < comments.length && i < numberToShow; i++){
var s=comments[i];s=s.substr(14,s.length-1); document.write(s);}
</script>
</ul></MainPage>

</div>
<!-- END FARRAGO RECENT COMMENTS HACK -->

IMPORTANT: this is a modified version only for my templates. You can find the original version on BloggerHack.

The hack code has two sections: the Options section and the Code section. You may modify the values of options in the Options section to customize the way the recent comments list will be displayed. numbertoShow may be set to any number from from 1 to 10 to customize the number of comments to display.

Save changes and enjoy it :)