« Dynamic Author Archives | Main | The Essential Movable Type Plugins List »

Movable Type Dynamic RSS Feeds

One feature that doesn't work "right out of the box" in Movable Type is dynamic RSS feeds. The reasons for this appear to be related to the implementation of the Smarty rendering engine in the dynamic publishing systems. Certain files required to enable dynamic RSS publishing aren't part of the Movable Type installation. This example will show how to create a dynamic RSS feed for authors, though the logic can be used for anything - categories, dates, comments, etc.

Note: You will need the PHP plugins for Smarty and Textile under dynamic publishing to use this technique. Place the files contained in the zip file into the /php/plugins directory under your Movable Type installation directory, i.e., the location of your MT.CGI file.
Using the default RSS 2.0 template in Movable Type 3.2 as a template, created a new Index Archive template called Authors RSS and set the output file as authors.xml. Make the template dynamically published by checking the Enable dynamic building for this template box. If the box is not available, you will need to change your publishing options in Settings|Publishing|Dynamic Publishing to : Set each template's Build Options separately.

Paste the default RSS 2.0 Index template into the editing screen and make the following two changes:

Change the first instance of MTEntries from: <MTEntries lastn="1"> to <MTEntries author="`$smarty.request.author`" lastn="1">

Change the second instance of MTEntries from: <MTEntries lastn="15"> to <MTEntries author="`$smarty.request.author`" lastn="1">

Save the template and test the authors.xml file by passing it the author variable on the command line, for example:

http://tech.wizbangblog.com/author/author.xml?author=Kevin%20Aylward


You can call the file directly from your template with code like this:

<a href="<$MTBlogURL$>index.xml?author=<$MTEntryAuthor$>"><$MTEntryAuthor$> RSS Feed</a>

The page should produce RSS 2.0 valid output containing only the entries written by the author passed on the command line. If you do not pass an author variable on the command line all authors are output. Note that sometimes a rebuild of the MTVIEW.PHP file is required before the feed is first published is required.

Given that not passing a variable will output all entries, it's possible to create a single dynamic RSS template that will handle your custom needs as well as your general needs. How you call the feed will determine the content.

A full copy of the completed template can be downloaded here: dynamic_rss.txt

  • Currently 0/5
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 0/5 (0 votes cast)


Close

Email this entry to:


Your email address:


Message (optional):


The comment section for this entry is now closed. To continue discussing this story visit the Wizbang Forum.


Advertisments







Archives

Categories