Date:Tuesday Jan 06, 2009

Roller Weblogger Archive Menu


Whenever I read my friends blogs who host on Blogger I always admire the archive menu that comes as standard; it's pretty neat and really helps when you have a large number of blog posts over a number of years (something that bothers me because if a reader enjoys a blog post I want to make it as easy as possibly for them to find other, similar and related posts, but more on this later).

So I mocked up this simple, yet effective, version which produces a similar, self-generating, archive menu list.

Here's an example:

And here's the code (and don't forget to change the $startYear and $startMonth variables to the year and month you started your blog as well as using your blog handle instead of 'eclectic'):


## Blog Start Year
#set ($startYear  = 2007)

## Blog Start Month
#set ($startMonth = 4)

## Get the current Year and Month
#set ($countYear  = $now.getYear() + 1900)
#set ($countMonth = $now.getMonth() + 1)

## Text Adjust

#set ($zero = 0)

## Total number of years to cycle through
#set ($numberYear  = $countYear - $startYear)

<ul class="rEntriesList">

#foreach ($number in [0..$numberYear])

  #if ($countYear >= $startYear)

    ## Months in a year
    #foreach ($number in [1..12])

      #if  (($countMonth != 0) && ((($countYear > $startYear) || (($countYear == $startYear) && ($countMonth >= $startMonth)))))

        <li class="recentposts">

        #if ($countMonth     ==  1)
          #set ($nameMonth = "January")
        #elseif ($countMonth ==  2)
          #set ($nameMonth = "February")
        #elseif ($countMonth ==  3)
          #set ($nameMonth = "March")
        #elseif ($countMonth ==  4)
          #set ($nameMonth = "April")
        #elseif ($countMonth ==  5)
          #set ($nameMonth = "May")
        #elseif ($countMonth ==  6)
          #set ($nameMonth = "June")
        #elseif ($countMonth ==  7)
          #set ($nameMonth = "July")
        #elseif ($countMonth ==  8)
          #set ($nameMonth = "August")
        #elseif ($countMonth ==  9)
          #set ($nameMonth = "September")
        #elseif ($countMonth == 10)
          #set ($nameMonth = "October")
        #elseif ($countMonth == 11)
          #set ($nameMonth = "November")
        #elseif ($countMonth == 12)
          #set ($nameMonth = "December")
        #end

        #if ($countMonth > 9)
          <a href="http://blogs.sun.com/eclectic/?date=$countYear$countMonth">» $nameMonth, $countYear</a>
        #else
          <a href="http://blogs.sun.com/eclectic/?date=$countYear$zero$countMonth">» $nameMonth, $countYear</a>
        #end

        </li>

        #set ($countMonth = $countMonth - 1)

      #end
 
    #end

  #set ($countMonth = 12)

##</ul>

  #end

#set ($countYear = $countYear - 1)

#end

</ul>



Online

Flickr

www.flickr.com

Where

Search

This blog only

Related

Language

Archive

Subscribe

 

Do the right thing

Join the Blue Ribbon Online Free Speech Campaign
Join the Online Free Speech Campaign!

kthxbai

Visitors

Locations of visitors to this page
  • » Large Cluster Map
  • » Unique Visitors:
  • Today's Page Hits: 8960