This hack combines two popular archive hacks with a new functionality in the same script. The two popular hacks included are the displaying of archive post counts in the archive list, and the re-ordering of the archive list. These two can be applied using the script with or without the third, new, functionality with is asyncronous loading of archives into the sidebar. If you don’t know what that means, try it out in my sidebar. Select an archive from the drop-down and notice that instead of being taken to the archive page, the posts in that archive are listed for you right in the sidebar. The steps to implement either part of this hack follow:
- Edit your blog template and add the following code directly after the <body> tag:
<ArchivePage>
<!– START ARCHIVE XOXO –>
<ul class=”xoxo posts” style=”display:none;”>
<Blogger><li><a href=”<$BlogItemPermalinkUrl$>”><BlogItemTitle><$BlogItemTitle$></BlogItemTitle></a></li></Blogger>
</ul>
<!– END ARCHIVE XOXO –>
</ArchivePage>Note: if you have your blog marked up using hAtom or the XOXO Blog Format this step is unnecessary.
- Add the following code into your sidebar where you want the archive list to display:
<div id=”archive_list”><i>Loading Archives…</i></div>
<div id=”archive_display”></div>
<noscript>
<ul class=”archive-list”><BloggerArchives>
<li><a href=”<$BlogArchiveURL$>”><$BlogArchiveName$></a></li>
</BloggerArchives></ul>
</noscript>Note to advanced users. The noscript section is necessary. You can edit it, but only if you pass two additional parameters to the function in the next step containing the code starting the list and ending the list.
- Add the following code into your <head> section:
<script type=”text/javascript” src=”http://jscripts.ning.com/get.php?xn_auth=no&id=1286814;
<script type=”text/javascript”>
//<![CDATA[
addLoadEvent(function(){get_archive_list(‘archive_list’,’archive_display’,’format‘,sort);});
//]]>
</script>Where format is drop if you want a drop-down archive list or list if you want the archives displayed in an unordered list. sort is true to sort the archive list oldest-to-newest and false to sort newest-to-oldest.
If you want the archive list to link to the archive pages instead of loading in the sidebar then delete the archive_display text from the code above.
- Save your template and republish your blog.
Advanced users may be interested in the information on the scripts behind this.