Skip to content

Instantly share code, notes, and snippets.

@CNG
Last active December 17, 2015 11:59
Show Gist options
  • Save CNG/5605968 to your computer and use it in GitHub Desktop.
Save CNG/5605968 to your computer and use it in GitHub Desktop.
mt:ArchiveList date context not as documented in 5.2.3
<mt:Ignore>
Want to do it like this, but it's outputting all months for every year...
http://www.movabletype.org/documentation/appendices/tags/archivelist.html
"Here, we're combining two ArchiveList tags (the inner ArchiveList tag is bound to the date range of the year in context)"
<mt:ArchiveList type="Yearly">
<mt:ArchiveListHeader><ul></mt:ArchiveListHeader>
<li><a href="<$mt:ArchiveLink$>"><$mt:ArchiveDate format="%Y"$></a>: </li>
<mt:ArchiveList type="Monthly" sort_order="ascend">
<mt:ArchiveListHeader><li></mt:ArchiveListHeader>
<a href="<$mt:ArchiveLink$>"><$mt:ArchiveDate format="%b"$></a>
<mt:Unless name="__last__"> / </mt:Unless>
<mt:ArchiveListFooter></li></mt:ArchiveListFooter>
</mt:ArchiveList>
<mt:ArchiveListFooter></ul></mt:ArchiveListFooter>
</mt:ArchiveList>
</mt:Ignore>
<mt:ArchiveList type="Yearly">
<mt:ArchiveListHeader><ul></mt:ArchiveListHeader>
<$mt:ArchiveDate format="%Y" setvar="outer_year"$>
<li><a href="<$mt:ArchiveLink$>"><$mt:ArchiveDate format="%Y"$></a>: </li>
<li style="margin-bottom:10px;">
<$mt:Var name="months" value=""$>
<mt:ArchiveList type="Monthly" sort_order="ascend">
<$mt:ArchiveDate format="%Y" setvar="inner_year"$>
<mt:If name="outer_year" eq="$inner_year">
<mt:SetVarBlock function="push" name="months">
<a href="<$mt:ArchiveLink$>"><$mt:ArchiveDate format="%b"$></a>
</mt:SetVarBlock>
</mt:If>
</mt:ArchiveList>
<mt:Loop name="months">
<$mt:Var name="__value__"$>
<mt:Unless name="__last__"> / </mt:Unless>
</mt:Loop>
</li>
<mt:ArchiveListFooter></ul></mt:ArchiveListFooter>
</mt:ArchiveList>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment