Dylan Tweney
Rough Drafts

Movable Type blogroll.

How to use Movable Type and PHP to manage a list of links automatically.
Dylan Tweney 2 min read

Movable Type continues to impress me with its flexibility and power. Last week I decided I’d had it up to here with maintaining the list of links that appears on the right side of my home page (the “blogroll,” as some people call it). Instead of manually editing HTML code in my weblog template, why not use MT to auto-generate a list of links, then use PHP to include this link list anywhere I needed it? Better still: MT’s categories feature would make it easy to group related links together.

You can see the results of this solution in my new “RESOURCES” list, on the right side of the Tweney Report home page.

Other people have probably found this solution themselves, but I’m posting it here in case it’s useful to anyone else.

How it works: I set up a new weblog called “quicklinks.” I entered each link into this new weblog as an entry, using MT’s fields as follows:

Title — the link’s title
Entry Body — the main URL for that link
Extended Entry — the corresponding RSS feed, if I could find it
Excerpt — a short, optional summary

I also assigned a category to each link: tech news, tech blogs, bookish sites, search tools, and so forth.

Then I created a new index template with the filename include.html. Here’s the complete code of that template:


<MTCategories>
<strong><$MTCategoryLabel$></strong>
<MTEntries sort_by=”title” sort_order=”ascend”>
<MTEntriesHeader>
<ul>
</MTEntriesHeader>
<li><a title=”<$MTEntryExcerpt$>” href=”<$MTEntryBody convert_breaks=”0″$>”><$MTEntryTitle$></a><MTEntryIfExtended> | <a title=”XML-RSS feed” href=”<$MTEntryMore convert_breaks=”0″$>”>RSS</a></MTEntryIfExtended></li>
<MTEntriesFooter>
</ul>
</MTEntriesFooter>
</MTEntries>
</MTCategories>

What this template does is spit out all of the “Quicklinks” entries, grouped by category, and ordered alphabetically within each category. Each entry appears as its name, hyperlinked to the main URL, with a link title that shows the site summary, if I entered one. If I entered a URL for the RSS feed, that shows up as an additional link. (Note: Entries that aren’t assigned to any category at all won’t show up in this list, and entries that are assigned to multiple categories should show up under each category they’ve been assigned to.)

I then published the Quicklinks blog and went back to my main weblog, the Tweney Report. Here I entered the following snippet of code into my main index template (a PHP file):


<?php include(“https://dylan.tweney.com/links/include.html”); ?>

This line uses PHP to bring in the “include.html” file created by the quicklinks blog.

Voil

Share
More from Dylan Tweney
Rough Drafts

Gratitude

The dogs have fleas. The cat keeps pooping on the kitchen floor. The house is of course a mess, and my daughter is graduating from high school tomorrow — assuming she got rid of that F in English.  Meanwhile, my wife is recovering from her 2nd eye surgery in a month, after two months of […]
Dylan Tweney 1 min read
Journalism in the Age of Online Collaboration
Rough Drafts

Journalism in the Age of Online Collaboration

Savvy journalists have adapted (or have been forced to adapt) to a new, more collaborative publishing model online. Here are my notes from a keynote presentation I delivered on this topic at the OCLC Collaboration Forum, held at the Smithsonian, on September 21. Matsuo Kinsaku was born around 1644 i
Dylan Tweney 6 min read

Dylan Tweney

If you're bored, you're not paying attention

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Dylan Tweney.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.