Archive Date Header Plugin

Freshness Warning
This article is over 17 years old. It's possible that the information you read below isn't current.

In the Movable Type support forums I’ve seen requests for the ability to group archives by date. Most of the time, people want to have an archive index that looks something like:

2002 August July June May April March February January

2001
December November October September August July June May April March February January

There have been a few people that have posted solutions using PHP or JavaScript, but I thought it would be nice to do this straight out of Movable Type.

Thus the Archive Date Header plugin was born.

Tim Appnel has taken over the maintenance and support of this plugin as of Oct 2004.

Download

You can get this plugin by downloading ArchiveDateHeader.zip

Installation

Unzip ArchiveDateHeader.zip and connect to your FTP server and open the directory where you have Movable Type installed.

Create a directory there called plugins if there isn’t one already and copy ArchiveDateHeader.pl to the plugins directory.

Using the plugin

Once you’ve installed the plugin you will have a new container tag, MTArchiveDateHeader. The tag only works within an MTArchiveList container tag, and if you try and use it elsewhere, you’ll receive an error.

If you use monthly archives, the contents of this container will only be printed when a new year starts.

If you use weekly archives, the contents of this container will only be printed when a new month starts.

If you use another sort of archive, the contents of this tag won’t be printed at all.

Here’s an example:

<MTArchiveList archive_type="Monthly">
<MTArchiveDateHeader>
<p><b><MTArchiveDate format="%Y"></b></p>
</MTArchiveDateHeader>
<a href="<$MTArchiveLink$>"><MTArchiveDate format="%B"></a> 
</MTArchiveList>

License

Like our other freeware, this plugin is released under the open-source MIT License. In plain English, that means you can do whatever you want with the software, including modifying it, selling it, or eating it, but we’re not responsible for anything that goes wrong.

Revision History

1.0 - August 4, 2002 Initial release.

tamaracks
October 6, 2002 12:27 AM

I'd like to see a tag for better formatting possibilities. For instance, I'd like to have the year, followed by the months as an unnumbered list, but there is no way to add a closing tag after the months with this plugin.

Richard
October 17, 2002 7:54 AM

It's nice. But I'd like to build a nested set of list elements. I can kick off a list with a *ul* in *MTArchiveDateHeader*, but without *MTArchiveDateFooter* I can't close it again with its */ul* tag.

Sparticus
January 24, 2003 6:20 AM

Is there anyway I can use both? so if I display my entries by weeks (which I do) it can then display... 2003 January 01/01/03-07/01/03 08/01/03-etc... Feburary 03/02/03-

Sparticus
January 24, 2003 6:30 AM

Nevermind I'm being slighty stupid... I've worked out a way of doing more or less the same thing

Brad
March 3, 2003 1:24 PM

This is a great little plugin, just what I've been looking for. But....is there a way to list only a single year?

Adam Kalsey
March 4, 2003 9:24 AM

There's no way to do that with the plugin or with the built-in MT template tags.

Peter
July 19, 2003 5:00 AM

How can I reverse the months? i.e. 2002 jan feb mar... 2001 jan mar apr...

Adam Kalsey
July 20, 2003 10:35 AM

What you'd need is a way of reversing the archive sort order. I don't MT can do that natively, but you might find a plugin that does it if you hunt around at http://mt-plugins.org

Rob Novak
August 22, 2003 6:07 AM

This is just what I've been looking for. Thanks for putting the time in on this plugin.

Rob Novak
August 22, 2003 6:46 AM

Found a bug. If the archive_type="Weekly", then a new header is generated for each archive entry. Here's the offending code: } elsif ($at eq "Weekly"){ $this_date = substr $ts, 5, 6; This extracts the 6-character substring starting at zero-based offset 5. Unforunately, this captures the 2nd digit of the month, the day, and part of the zero-padding. So, it's unique for each entry. These lines should read: } elsif ($at eq "Weekly"){ $this_date = substr $ts, 4, 2; Grab the 2 characters (the month) at zero-based offset 4. The datestamp from $ts is chars 0-3 (year), 4-5 (month), and 6-7 (day).

Rob Novak
August 22, 2003 8:01 AM

If you want to handle Daily archives with per-month headers as well, the following if..elsif..else statement will do it nicely: if ($at eq "Monthly") { $this_date = substr $ts, 0, 4; } elsif ($at eq "Weekly"){ $this_date = substr $ts, 4, 2; } elsif ($at eq "Daily"){ $this_date = substr $ts, 4, 2; } else { return ''; }

Peter
September 4, 2003 8:27 AM

Forgot to thank you so.. Thanks :)

dvd
November 18, 2003 2:02 PM

To generate nested lists of archives you can use this plugin together with Brad Choate's MTPerlScript plugin, with your template something like this: ----- <ul> <MTArchiveList archive_type="Monthly"> <MTArchiveDateHeader> <li><$MTArchiveDate format="%Y"$> <ul> </MTArchiveDateHeader> <li><$MTArchiveDate format="%B"$></li> <MTPerlScript> $a = '<MTArchivePrevious><$MTArchiveDate format="%Y"></MTArchivePrevious$>'; $b = '<$MTArchiveDate format="%Y"$>'; if ($a ne $b) {print "</ul></li>"}; </MTPerlScript> </MTArchiveList> </ul> ----- Example of output: <ul> <li>2003 <ul> <li>February</li> <li>January</li> </ul> </li> <li>2002 <ul> <li>December</li> <li>November</li> <li>October</li> </ul> </li> </ul>

Trackback from BLOG:RED BICYCLE RECORDS
September 17, 2004 11:30 PM

月別アーカイヴを手短に

Excerpt: しました。 Archive Date Header Pluginを入れて。 ソースも書いてあるので、そちらを参考に。...

Trackback from BnKB
February 16, 2005 11:50 PM

Archive Date Header Plugin

Excerpt: In the Movable Type support forums I’ve seen requests for the ability to group archives by date. Most of the time, people want to have an archive index. There have been a few people that have posted solutions using PHP...

These are the last 15 comments. Read all 19 comments here.

This discussion has been closed.

Follow me on Twitter

Best Of

  • Simplified Form Errors One of the most frustrating experiences on the Web is filling out forms. When mistakes are made, the user is often left guessing what they need to correct. We've taken an approach that shows the user in no uncertain terms what needs to be fixed.
  • Pitching Bloggers Forget what you learned in your PR classes. Start acting like a human instead of a marketer, and the humans behind the blogs will respond.
  • How not to apply for a job Applying for a job isn't that hard, but it does take some minimal effort and common sense.
  • Embrace the medium The Web is different than print, television, or any other medium. To be successful, designers must embrace those differences.
  • Newly Digital Newly Digital is an experimental writing project. I've asked 11 people to write about their early experiences with computing technology and post their essays on their weblogs. So go read, enjoy, and then contribute. This collection is open to you. Write up your own story, and then let the world know about it.
  • More of the best »

Recently Read

Get More

Subscribe | Archives

Recently

Building the Customer-Informed Product (Aug 15)
Strong products aren't composed of a list of features dictated by customers. They are guided by strong visions, and the execution of that vision is the primary focus of product development.
Assumptions and project planning (Feb 18)
When your assumptions change, it's reasonable that your project plans and needs change as well. But too many managers are afraid to go back and re-work a plan that they've already agreed to.
Feature voting is harmful to your product (Feb 7)
There's a lot of problems with using feature voting to drive your product.
Encouraging 1:1s from other managers in your organization (Jan 4)
If you’re managing other managers, encourage them to hold their own 1:1s. It’s such an important tool for managing and leading that everyone needs to be holding them.
One on One Meetings - a collection of posts about 1:1s (Jan 2)
A collection of all my writing on 1:1s
Are 1:1s confidential? (Jan 2)
Is the discussion that occurs in a 1:1 confidential, even if no agreed in the meeting to keep it so?
Skip-level 1:1s are your hidden superpower (Jan 1)
Holding 1:1s with peers and with people far below you on the reporting chain will open your eyes up to what’s really going on in your business.
Do you need a 1:1 if you’re regularly communicating with your team? (Dec 28)
You’re simply not having deep meaningful conversation about the process of work in hallway conversations or in your chat apps.

Subscribe to this site's feed.

Contact

Adam Kalsey

Mobile: 916.600.2497

Email: adam AT kalsey.com

Twitter, etc: akalsey

Resume

PGP Key

©1999-2019 Adam Kalsey.