Tips and Tricks
Movable Type is a complicated application, and as you may have guessed from some of the sections earlier in this chapter and in Chapter 5, a very powerful application. This section contains some tips and tricks that may not be readily apparent via the Movable Type manual: how to display a random entry from your blog, how to display the last n non-consecutive days of entries on your blog, and so on.
Displaying a Random Entry
A common request from users is the ability to display a random entry from their blogs on one of their pages. This can be useful in driving traffic to your site archives. By providing visitors with a teaser of one of your older entries, you could hook them for hours as they trawl through your archives, looking for similar gems.
Because Movable Type produces completely static pages, there is not a built-in set of tags for displaying a random entry on your public site. It is fairly simple, however, to add this feature using a post-processing tool such as PHP or server-side includes. Following is an example of using PHP to include a random entry:
Log in to Movable Type and select the blog containing your entries.
Click the Templates button to manage your templates.
Click on the Create New Index Template link.
Set the name of the template to Random Entry Pool, set the Output file to
entry-pool.dump, and set the body of the template to the following:
<MTEntries lastn="100"> <$MTEntryTitle$> <$MTEntryLink$> <$MTEntryExcerpt$> -------- </MTEntries>
Save the template. ...