Further Sidebar Tweaking #

In my quest to further simplify/improve the sidebar, I've decided that having both a "Categories" and a "Recent Posts" list was too space consuming and not all that useful (when reading other people's sites I don't usually make much use of the recent entries list, instead I just go from page to page (whether they be per entry, day or month)). The idea was to combine the two in a way very similar to the "Monthly" list*, with each category name and a couple of recent entries under each one. The initial code was very simple:

<MTArchiveList archive_type="Category">

   <span class="archiveListHead"><a href="<$MTArchiveLink$>"><$MTArchiveTitle$></a></span><br />

   <MTEntries lastn="2">
      <span class="archiveSubList"><a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a></span><br />
   </MTEntries>

</MTArchiveList>

This achieved what I had initially intended, but ironically enough it turned out that's not quite what I wanted. This listed the most recent couple of entries for all categories, even those in which I hadn't written in ages, like Grendel and Meshroom. Ideally I would place some kind of restriction, so that only entries within, say, the past 30 days would be listed. Unfortunately the MTEntries doesn't support combinations of the lastn and days attributes. Turning to the MT plugin archive, I found DateTags. It seemed like its MTDateLoop tag would let me loop within entries of the past 30 days. However, it didn't seem to respect neither the Category context that it was in, nor the lastn parameter for the MTEntry. Doing those comparisons by hand didn't seem all that fun (and would probably have required more plugins to be downloaded), so I looked for another way.

The final solution still required more plugins, but it was to very simple, straight-to-the-point ones: MT-Epoch and Compare. Using MT-Epoch I can convert dates to epochs (seconds since Jan. 1, 1970) and then subtract the entry date from the current date, printing only those entries where the difference is less than 30 x 24 x 60 x 60 = 2,592,000. This meant adding these two lines just inside the MTEntries block:

<MTIfLess numeric="1" a="[MTDate convert_to_epoch='1'] - [MTEntryDate convert_to_epoch='1']" b="2592000">
entry listing code..
</MTIfLess>

However, it then turned out that Compare, even when in numeric mode, doesn't evaluate expressions (not MT ones, arithmetic ones). Fixing this was a simple manner of adding a couple of eval's after embedded expressions were expanded.

The lesson from all of this is that presumably there is a point at which it becomes more time-effective to either start writing my own plug-ins or even my own journal/CMS system. We'll see.

* While browsing around the MT plugins directory, I also happened upon DateHeaders, which appears to the same thing as my MTMacro/ArchiveYear combination. A rewrite is in order at some point.

Post a Comment