Dog/Blog House Updates Part Trois

Another squirrely thing about MovableType right out of the box is that the category archive templates it create is more or less a never-ending appending of your posts to a long scrolling archive. It hardly seems useful once you have blogged say 10, 20 entries in a category, much less if you have written long pieces and/or embedded images.

Previously I wrote about my funky strategy for creating two sets of category archives, the recent 20 linked to “all the rest”, but I have modified the output templates to produce more or less a title/abstract view (example) rather than a mimic of the original post, with a link to the full post (the individual archive, old example)…

This is pretty easy, it is a modification of your Category Archive template, and replacing the part between the <MTEntries>...</MTEntries> tags with something more like:


<MTEntries><$MTEntryTrackbackData$><p><a href="<$MTEntryPermalink$>"><strong><a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a></strong> (<$MTEntryDate format="%x"$>)<br /><$MTEntryBody words="50"$>... «<a href="<$MTEntryPermalink$>">more</a>»</p></MTEntries>

Being in the Category Archive template context, this pulls data from only one category at a time, so it loops through all the entries for a category named, say, “Foo”. It first embeds the TrackBack data for that entry (hidden code, but useful).

Next it spits out the entry title, puts it in bold (<strong>.. </strong>tags), and hyperlinks the title to the individual; entry. This is followed by a readable date format for when the entry was posted. Then, it echos just the first 50 words from the entry. “…” with a redundant “more” link that again leads to the full entry.

There are more things one could do- I do not have the comment/trackback count added here (“left as an exercise for…” you know that song), but the result is a more compact listing of the entries for each category.

Creative Commons License
The Dog/Blog House Updates Part Trois by CogDogBlog, unless otherwise expressly stated, is licensed under a Creative Commons Attribution 3.0 United States License.

Comments are closed.

Dog/Blog House Updates Part Deux

More changes I forgot in the MovableType structure of CDB. Previously, when I had a poor grasp on MT templates, I had separate index templates for each of my category RSS feeds, thinking there was not a way to generalize that. This was sloppy, requiring new templates for every category I decided to add, and the more index rebuilds you ask MT to do, it seems to get a bit clunkier.

Here is how I created generalized RSS feeds (okay, they are still RSS 1.0, but I’ve yet to figure out why I need 2.0 or pie or Atom or whatever else it is called these days. I am open to having my paw slapped)…

You create the templates for your MT archives RSS feeds not in the top sections, the index templates (leave the RSS feed there for your overall site), but in the second block of templates, Archive Related Templates.

First, follow the link to “Create a New Archive Template”. I called mine Category RSS 1.0 but it would not make a hill of bean difference if you named it Barney Rubble. It is more or less a copy of the out of the box RSS 1.o index template, with a few substitutions noted below:

<?xml version="1.0" encoding="<$MTPublishCharset$>"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:cc="http://web.resource.org/cc/" xmlns="http://purl.org/rss/1.0/"><channel rdf:about="<$MTBlogURL$>"><title><$MTBlogName encode_xml="1"$>: <$MTArchiveTitle$></title><link><$MTBlogURL$>archives/<$MTArchiveCategory dirify="1"$>.html></link><description>CDB Latest on <$MTArchiveTitle$></description><dc:language>en-us</dc:language><dc:creator></dc:creator><dc:date><MTEntries lastn="1"><$MTEntryDate format="%Y-%m-%dT%H:%M:%S" language="en"$><$MTBlogTimezone$></MTEntries></dc:date><admin:generatorAgent rdf:resource="http://www.movabletype.org/?v=<$MTVersion$>" /><MTBlogIfCCLicense><cc:license rdf:resource="<$MTBlogCCLicenseURL$>" /></MTBlogIfCCLicense><items><rdf:Seq><MTEntries lastn="15"><rdf:li rdf:resource="<$MTEntryPermalink encode_xml="1"$>" /></MTEntries></rdf:Seq></items></channel><MTEntries lastn="15"><item rdf:about="<$MTEntryPermalink encode_xml="1"$>"><title><$MTEntryTitle encode_xml="1"$></title><link><$MTEntryPermalink encode_xml="1"$></link><description><$MTEntryExcerpt encode_xml="1"$></description><dc:subject><$MTEntryCategory encode_xml="1"$></dc:subject><dc:creator><$MTEntryAuthor encode_xml="1"$></dc:creator><dc:date><$MTEntryDate format="%Y-%m-%dT%H:%M:%S" language="en"$><$MTBlogTimezone$></dc:date></item></MTEntries></rdf:RDF>;

All I have done is used the <$MTArchiveTitle$> tag to pull out the name of the archive (as defined in the attributes section of each category you define in MT) to make the title and description relevant to the category, as well as pulling out the link to the category archive– in this example, the archives are based on the name of the archive and referenced inside my “archives/” directory, so “Objects” category would reference the archive template created in:

/archives/objects.html

your naming scheme may be different. The point here is that used in the context of a Category Archive template, the various <$MTArchiveXXX$> tags will pull out the necessary information for the context of each category you define.

So you create the general template, but you are not done. Next you must go to the WebLog Config panel, and click the Archiving link. Under “Archive Type” at the bottom click “Add new…” This brings a popup menu, where you should select under “Archive Type” (top menu) Category Archive and under the “Template Menu” select the name of the new template you created above, e.g. Category RSS 1.0.

Click the “Add” button and this new entry should be added to your last set of Category archives (this one should not be selected by the radio buttons; that ons is the template for your category web page). There is one more thing to do- in the empty field under Archive File Template, you can again use MT tags to intelligently name your RSS files, e.g. mine are:

cat_<$MTArchiveCategory dirify="1"$>.xml

which converts the name of every category archive I created to a web friendly file name, e.g.

the objects categoryu archive has its rss feed:

http://cogdogblog.com/alan/archives/cat_rss.xml

and the “web bad dog” archive has an rss feed of:

http://cogdogblog.com/alan/archives/cat_web_bad_dog.xml

The beauty here is that if I add new categories, or change the names, etc, and rebuild, all my category RSS files are changed automatically.

Again, you have to Rebuild all of your category archives to see the changes.

Templates = power.

Creative Commons License
The Dog/Blog House Updates Part Deux by CogDogBlog, unless otherwise expressly stated, is licensed under a Creative Commons Attribution 3.0 United States License.

Comments are closed.

Recent Barks and Howls: