« September Network Traffic | Main | Pruning Your Email List »

Recent Posts in Movable Type

I've never liked how Movable Type handles Recent Entries. They only show up on the main index page, the very place where your recent posts are already displayed. Why show a list of titles in the sidebar, when you're already displaying the entries themselves. Here's how I 'fix' that so recent entries show up elsewhere, but not on the main page. The beauty of this approach is that you don't even have to republish to have Recent Entries show up on all your pages even if they're static.

Note: If you're generating template pages dynamically, then you can skip ahead to step 4.

Step 1: this 'fix' requires the use of server side includes (SSI). In Plesk or Cpanel you may be able to turn this feature on for your web site. If not, the direct way is to add the following line to your .htaccess file.

AddHandler server-parsed .html

The .htaccess file is normally found in your web site's root folder. You may or may not be able to see it via FTP, you may need shell access. If it doesn't exist, create it.

This file tells the Apache webserver how to handle the content of this folder, and all sub-folders. This particular command tells Apache to process all .html files for server side includes.

Step 2: create a 'page' that contains a list of your recent posts. This page will eventually be included wherever you need it. Create a index template in MT with the following content.

<div class="widget-archives widget">
<h3 class="widget-header">Recent Entries</h3>
<div class="widget-content">
<ul class="widget-list">
<MTEntries lastn="10">
<li class="widget-list-item"><a href="<$MTEntryPermalink$>" title="<$MTEntryExcerpt>"><$MTEntryTitle$></a></li>
</MTEntries>
</ul>
</div>
</div>

Have it publish to a file, say 'recent.html'. Whenever you update a post it gets recreated like any other index page. Here's what one of my files looks like:

      <div class="widget-archives widget">
            <h3 class="widget-header">Recent Entries</h3>
            <div class="widget-content">
                <ul class="widget-list">
    
                    <li class="widget-list-item"><a href="http://www.fridaynightdm.com/2007/04/ptolus-campaign.html" title="I'm starting a new campaign based on Ptolus City by the Spire by Monte Cook. I quite like the book, though I think it's going to be more work to run the included adventures than I had hoped.">Ptolus Campaign</a></li>
    
                    <li class="widget-list-item"><a href="http://www.fridaynightdm.com/2007/01/renew-dungeon-magazine-or-not.html" title="I've got two months left in my subscription to Dungeon Magazine and I'm wondering whether to renew or not. Not playing D&D much lately I'm basically just having a quick look at the comics and filing them away. And if...">Renew Dungeon Magazine or not?</a></li>
    
                    <li class="widget-list-item"><a href="http://www.fridaynightdm.com/2006/07/charsaphix.html" title="Charsaphix is similar to the CR9 black dragon from the Monster Manual but with one fix in a feat and some other minor changes.">Charsaphix</a></li>
    
                    <li class="widget-list-item"><a href="http://www.fridaynightdm.com/2006/05/new-dd-miniatures-gulgar.html" title="I just got some new minis yesterday. A booster back from the War Drums set. Initiallly I was disappointed, but after looking at the set more closely I kind of like it....">New D&D Miniatures - Gulgar</a></li>
    
                </ul>
            </div>
        </div>

The above code is for MT4, you should style it to match your sidebar text and links. This code will create a list of links based on the titles of recent posts. It also uses a 'title' attribute so that the excerpt for the post shows up if the viewer hovers over the link.

Step 3: modify your templates to put this into your sidebar. In MT 3.xx you'll probably have to modify each index and archive template. In MT4 you can update the 2 or 3 column sidebar template module.

 <MTIf name="module_recent_entries">
<!-- <div class="widget-archives widget">
<h3 class="widget-header">Recent Entries</h3>
<div class="widget-content">
<ul class="widget-list">
<MTEntries lastn="10">
<li class="widget-list-item"><a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a></li>
</MTEntries>
</ul>
</div>
</div> -->
<!--#include virtual="/recent.html" -->
</MTIf>

In the above, I've commented out the old code. You can probably just delete it. The important line is the include statement.

Step Four: adjust which templates the Recent Entries will appear in. In the Main Index template, remove the following line.

<MTSetVar name="module_recent_entries" value="1">

Then take that line, and add it to your archive templates: Entry, Entry Listing, and Page. This will add a Recent Entries section to each post, each archive page, and each 'page'. That way, no matter how people enter your site, then can always see what's new.


© 2016 Mike Silversides

About

This page contains a single entry from the blog posted on October 2, 2007 8:27 AM.

The previous post in this blog was September Network Traffic.

The next post in this blog is Pruning Your Email List.

Many more can be found on the main index page or by looking through the archives.