February 07, 2010 -- If you post to your blog freqently, Blogger has a useful gadget that allows you to display an Archive of your posts.
In your Dashboard you can select Settings > Archiving and choose an Archive Frequency of Monthly, Weekly, Daily, or No Archive. When you go to add the Blog Archive Gadget, it would appear that you can again select an Archive Frequency of Monthly, Weekly, or Daily.

What is not clearly obvious, is that this overrides the setting made in the Dashboard. You may only use one Blog Archive gadget, so if you would like an archive by week, as well as an archive by month, this is not readily possible.
What I still really wanted was multiple archives presented in a format that didn't take up too much precious sidebar space. A drop-down box would be ideal.

I looked at using the Labels gadget, but I found this a bit too restrictive, in that I could not sequence the list in my own way, and eventually this list would become very long.

However, the Labels gadget did lead me to a solution. While there are likely several approaches to this with more complex programming, I found a fairly simple approach that is easily maintained without editing my blog template.
The Blogger Archive gadget produces a URL list based on the specific archiving option you selected. Assuming you have selected monthly archiving, you will have pages named blogname.blogspot.com/2010_02_01_archive.html for example, which will include all posts for the month of February 2010.
The Blogger Labels gadget differs from the Archive gadget by producing a URL list formated as blogname.blogspot.com/search/label/{label}. Thus, when you click on a link in your Labels gadget, Blogger returns a page listing any and all posts with {label} in the Labels box (entered while editing a post). The Labels option (to display Labels at bottom of posts) does not have to be selected in the Post Page options for this feature to work.
In the example above {label} represents any words you enter as a post label. Multiple labels are separated by a comma. If spaces are used they will be replaced in the URL link as %20. Since my intent was to produce a Weekly Archive, I chose to add labels such as "Feb 07 - Feb 13 2010" or "Jan 31 - Feb 06 2010" without the quotes, and without imbedded commas.
To implement my alternate archive gadget I simply added an HTML/JavaScript gadget to my blog and inserted the following code to produce a both a Weekly and Monthly archive drop-down box:
<form name="week">
<select onchange="window.location=document.week.weeklinks.options[document.week.weeklinks.selectedIndex].value" name="weeklinks">
<option value'""/>Weekly News Archive
<option value="/search/label/Feb%2007%20-%20Feb%2013%202010"/>Feb 07 - Feb 13 2010
<option value="/search/label/Jan%2031%20-%20Feb%2006%202010"/>Jan 31 - Feb 06 2010
<option value="/search/label/Jan%2024%20-%20Jan%2030%202010"/>Jan 24 - Jan 30 2010
<option value="/search/label/Jan%2017%20-%20Jan%2023%202010"/>Jan 17 - Jan 23 2010
</select>
</form>
<form name="month">
<select onchange="window.location=document.month.monthlinks.options[document.month.monthlinks.selectedIndex].value" name="monthlinks">
<option value=""/>Monthly News Archive
<option value="/2010_02_01_archive.html"/>February 2010
<option value="/2010_01_01_archive.html"/>January 2010
</select>
</form>
Similar to this blog at the top of the right hand sidebar, the above code produces two drop boxes that look like this (links not active in example below). The use of the Javascript in the <select> option removes the requirement for a GO button.
Again, there are other ways to accomplish similar results. With a little imagination, you will be able to create any number of archive "views" of your article posts based on included labels.
In practice, my weekly archive requires a code update once per week (on Sunday) and my monthly archive requires an update once per month (on the 1st) by simply adding one additional <option> line for each.
--MLJ
1 comments:
its nice informative post.its interesting
Post a Comment
Comments and suggestions are welcome. If you are having specific problems, please provide enough details for us to followup with possible solutions.