Blogger Hack: Alphabetizing Entry Index
This code will take all the entries on the page and list them in alphabetical order, creating an index. This can be useful, for example, if your blog is a series of book/movie reviews, and you title your entries with the title of the books/movies. It’s less important to the reader, in this instance, what date the review was posted on than the subject of the review.
It is based upon the code Blogger has on its help pages to list the archive links on the main page in reverse chronological order.
Place the code in the sidebar of your template, using <MainOrArchivePage>, <ArchivePage>, or <MainPage> tags to indicate which pages you want indexed.
Here is the code:
<ul class=”archive-list”>
<script type=”text/javascript”>Â
var archives = new Array();
function mysortfn(a,b) {
if (a[1]<b[1]) return -1;
if (a[1]>b[1]) return 1;
return 0;
}
<Blogger>
<BlogItemTitle>
archives[archives.length] = new Array(’<$BlogItemNumber$>’, ‘<$BlogItemTitle$>’);
</BlogItemTitle>
</Blogger>
archives.sort(mysortfn);
for (var i=0;i<=archives.length-1;i++)
{
document.write(’<li><a href=”http://transylvaniandutch.com/td/wp-admin/post.php#’ + archives[i][0] + ‘”>’ + archives[i][1] + ‘</a></li>’);
}
</script>
</ul>
An example of the results of this code can be viewed at comicspoilers
Last 5 posts in General
- When will it end? - July 2nd, 2009
- Worst fears realized - June 28th, 2009
- Cause of Crop Circles in Australia - June 25th, 2009
- June 12: Reasons to Celebrate - June 12th, 2009
- Maybe the chimp can tell me... - May 26th, 2009
Last 5 posts in Tech
- WolframAlpha Passover Matzah - May 17th, 2009
- NaPoWriMo Poem #15 and #16 - April 17th, 2009
- Rights, Wrongs and Facebook - February 18th, 2009
- Follow Me/Follow You - January 4th, 2009
- IT Flashback - October 9th, 2008
WordCount: 247
Gunning-Fog: 11.7348546191
Flesch-Kincaid: 9.60128082444
Flesch: 66.2201545823





11/18/2005 - 16 Heshvan, 5766 at 10:52 am
Is there a way to do this to our whole archives, or does this only work for what’s on our page now?
11/18/2005 - 16 Heshvan, 5766 at 11:02 am
It works for any page…the main index page, or single archive pages, but it won’t create a listing of multiple archive pages.
11/18/2005 - 16 Heshvan, 5766 at 11:21 am
If you want to place it on just your index page enclose the code within <MainPage> and </MainPage> tags.
If you want it just on your archive pages enclose the code between <ArchivePage> and </ArchivePage> tags.
If you want it on both, enclose the code between <MainOrArchivePage> and </MainOrArchivePage> tags.
3/13/2007 - 23 Adar, 5767 at 2:55 pm
Hi John,
Thanks for this hack, which will be useful to me. I was wondering if there is a way to show titles with a certain tag. For example, I may have movie and book reviews, and I would like to have two drop-down lists - one for movies, and one for books. How would I include the titles with a particular label? label = “book review”, or label = “movie review”)
Thanks a lot!
-Amit
1/5/2008 - 27 Tevet, 5768 at 10:02 am
I would really appreciate it if you could tell me what the first two or three lines of code in the New Blogger template to search for that this needs to go after. I have done some HTML but the code in the templates on Blogger is greek to me.