Skip to content

Instantly share code, notes, and snippets.

@davidpmccormick
davidpmccormick / twelve-month-archive
Created February 28, 2012 10:47
displays the previous twelve months in a list, formatted as words, with links in the form, '2012-01' for year and month, in order to be filtered for an archive view
<xsl:template name="months"> <!-- display a list of linked month numbers (from 12 to 00) counting back from current month for archive pages -->
<xsl:param name="thismonth" select="$this-month"/> <!-- month number -->
<xsl:param name="countmonths" select="12"/> <!-- months in a year -->
<xsl:if test="$countmonths &gt; 0">
<xsl:choose>
<xsl:when test="$thismonth &gt; 0"> <!-- if it's bigger than 0 -->
<xsl:choose>
<xsl:when test="string-length($thismonth) = 1"> <!-- if there's no preceding zero -->
<a href="{$root}/blog/archive/{$this-year}-0{$thismonth}">
<li class="month-0{$thismonth}">