« Trackback Ping From To Host Yourself | Main | Movable Type Dynamic RSS Feeds »

Dynamic Author Archives

For Movable Type users getting author archives is something akin to cracking The DaVinci code. While Movable Type includes many different template types by default, there is no provision for creating Author Archives. There have been a variety of hacks proposed throughout the years and in some future version of MT such a feature may be made available.

Where does that leave current MT users? Exactly nowhere, until now. Provided below is code that will allow you to create a single Movable Type template that will serve as the archive page for EVERY author in your on your blog.

Requirements:

  1. You must have the ability to run PHP pages. In most cases it's as simple as designating the Output To File setting with a .php extension.
  2. You must be using a version of Movable Type that supports dynamic pages (MT version 3 and above).

That's it for the requirements.

Create a new Index template named Author Archive (or any other name you like) and set the output file to be authors.php.

Starting at the body section use the following code to setup the page to receive the author name via the command line and enable dynamic navigation of the archive.

Starting at the body section, here's the relevant code:

<body>

<div id="banner"></div>
<div class="description"><$MTBlogDescription$></div>
<div id="blog">

<div id="menu">
{{$smarty.request.author}} Archives
</div>

<p align="right">
{{if $smarty.request.start > 0}}
<a href="?author={{$smarty.request.author}}&start={{$smarty.request.start-25}}">Previous</a>
{{/if}}

<MTEntries lastn="1" offset="`$smarty.request.start+25`">
{{if $smarty.request.start > 0}} | {{/if}}
<a href="?author={{$smarty.request.author}}&start={{$smarty.request.start+25}}">Next
</MTEntries>

<div class="blogbody">

<MTEntries author="`$smarty.request.author`" lastn="25" offset="`$smarty.request.start`">

Notice that the last line is the one that actually turns your MTEntries statement into a dynamic powerhouse. Just enter your normal code from your Main Index after that point and up to the <MTEntries>. You may not use the same DIV ID's as show in the example above, but a little searching of your templates should point you to the lines that need to be changed. Remember only the last line of the code is required for the Author Archive to work, the rest of the Smarty code is used to setup the dynamic navigation.

You call the page by passing it a parameter in the URL string, for example: authors.php?author=Joe%20Smith. But wouldn't it be better if you could dynamically generate that string on the Posted By: line? Of course it would...

Use something like this on the Posted By: line in your Main Index template and your Individual Archive template:

<a href="<$MTBlogURL$>authors.php?author=<$MTEntryAuthor$>"><$MTEntryAuthor$></a>
That will generate a link to each authors individualized author archive page.

As a bonus, if you use the code above each page will have a Previous and Next link that will allow you to page through their posts 25 at a time. You can change the number posts to show on each page by editing the smarty.request.start value above. For an example of how you can combine the dynamic navigation and author archiving for an author with thousands of posts see my author archive page at Wizbang.

  • Currently 5/5
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 5/5 (1 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