15 April 2010

Display links to recent comments on Blogger sidebar

 
*bump*
(reposted 15 June, 15 March, 15 September, 15 November 2009; 15 September, 15 November, 1 July 2007; 1 November, 1 August, 1 February 2006; 1 October 2005)
(originally posted 17 April 2005)

**********************************************


You can display links to recent comments on the sidebar by adding the recent comments hack

Add up to 10 links to most recent comments on your blogger sidebar. Go to: Found at:

recent comments hack from bloggerhacks.blogspot.com (http://bloggerhacks.blogspot.com/2004/09/farrago-recent-comments-hack-103.html)

to see how. Select ALL of the following coding. Copy and paste it into your sidebar coding where you want to see the recent comments listed.


<!-- **** FARRAGO RECENT COMMENTS HACK **** -->
<!-- Version 1.03 -->
<!-- Copyright &copy; 2004 Ebenezer Orthodoxy -->
<!-- was at http://boggerhacks.blogspot.com -->
<!-- ************** OPTIONS *************** -->
<script type="text/javascript" language="JavaScript1.2">
var titleText = "Recent Comments"; // heading on sidebar
var numberToShow = 5; // number of comments to show on sidebar
var displayTemplate = "[name]:<br/>[title]"; // formatting of comment link
var nameIsLink = true; // whether to add links to commenters' profiles
</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>
<MainPage><h2 class="sidebar-title">
<script type="text/javascript" language="JavaScript1.2">
document.write(titleText+'</h2>');</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><br/><br/><span
style="font-size:7pt;text-align:center;width:100%;border-top:1px dashed;">
<a title="Farrago Recent Comments Hack from BloggerHacks was at http://bloggerhacks.blogspot.com"
name="bloggerhacks.blogspot.com">BloggerHacks</a> </span>
</ul></MainPage>
<!-- END FARRAGO RECENT COMMENTS HACK -->


To customize the hack, look for
var titleText = "Recent Comments"; // heading on sidebar
You can put anything you want inside the quotation marks.

To change the number of recent comments that are shown on the sidebar, look for:
var numberToShow = 5; // number of comments to show on sidebar
Where the "5" is, you can type any number between 1 and 10

To customize what is shown for each link, look for:
var displayTemplate = "[name]:<br/>[title]"; // formatting of comment link
[name] is the name of the commenter; <br/> puts a line break after the name of the commenter; [title] is the title of the post being commented on.

To link to commenters' profiles or not, look for:
var nameIsLink = true; // whether to add links to commenters' profiles
true adds the link; false displays just the commenters' names without linking to their profiles.

2 comments:

ejm said...

Add up to 10 links on your blogger sidebar to most recent comments. Go to:

http://bloggerhacks.blogspot.com/2004/09/farrago-recent-comments-hack-103.html

to see how.

ejm said...

bloggerhacks.blogspot.com is no longer there. But the recent comments hack still works. Use the coding in the post.