O'Reilly logo

Essential Blogging by Mena G. Trott, Benjamin Trott, Shelley Powers, Scott Johnson, Rael Dornfest, Cory Doctorow

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. Log in to Movable Type and select the blog containing your entries.

  2. Click the Templates button to manage your templates.

  3. Click on the Create New Index Template link.

  4. 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>
  5. Save the template. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required