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

Movable Type blogroll.

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

11 Comments

  1. Harry Fuecks

    Like the idea but one thing on security;

    If include.html contains any PHP, the remote site reading your URL will *execute* it. Kind of a dangerous situation…

    Perhaps better would be on the remote site;

    PHP 4.3.0+
    echo ( file_get_contents(“https://dylan.tweney.com/links/include.html”) );

    PHP < 4.3.0

    echo ( implode(”,file(“https://dylan.tweney.com/links/include.html”)) );

  2. Anders

    Cool idea! I’ve been playing with something similar for a photoblog template (using some of the additional fields for file names etc..)

    Well done 🙂

    Next; using your setup below and generating PHP blogroll(s) sorted by updates (see: http://www.philringnalda.com/phpblogroll/ for more inspiration 🙂

  3. wuji

    Wow.. such a great idea! I think I will have to incorporate something like this into my own weblog! Thanks for sharing!

  4. Scott Johnson

    As soon as I read your article, I just had to add this functionality to my site. I don’t have the categorization established yet, but that will be up soon. Thanks for taking the time to write up such an informative article!

  5. Dylan Tweney

    Harry, your comment about security is apt, and if anyone is thinking of pulling a links file from someone else’s site (like mine) you should definitely follow his advice. However, since I’m pulling the file from my own site, I have control over that HTML file that’s getting included. Perhaps I should have written that PHP code thus:

    include(“links/include.html”);

    Anders, I like the idea of using data from weblogs.com to figure out which weblogs on the list were most recently updated. Clever!

    Thanks to the rest of you for your comments!

  6. Michael Hanscom

    Isn’t MT great? I’m using a similar technique for the ‘sideblog’ at my TypePad site. Details on my particular implementation are here.

  7. Dave Taylor

    Not only is MT a good tool, Dylan, but it makes it quite easy to have more than one weblog on the same code base. I have four running off a single MT installation: http://www.intuitive.com/blog/ is my main weblog (The Intuitive Life), but I also run http://booktalk.intuitive.com/ my booktalk weblog, http://www.APparenting.com/ for attachment parenting (half-unbuilt, but still quite busy!) and a private password-only weblog for an entrepreneurial group I’m in…

    Oh, and HI Dylan! Long time, my friend….

  8. Mark Mascolino

    Great idea. I was able to take you idea and use the OtherBlog plugin ( http://mt-plugins.org/archives/entry/otherblog.php ) to accomplish the samething without using PHP. Details: http://people.etango.com/~markm/archives/2003/10/08/easy_movable_type_blogrolls.html

    Its quite nice and thanks for the inspiration.

  9. Jean-Fran

    Thanks for this wonderful articles and thanks to all those who added valuable comments.

    Using the php feature obliges you to turn your MT pages into php format with .php extention. Useful information for this is visible at http://www.virtualvenus.org/wiki/view/MT/ConvertingToPHP.

    The MTOtherBlog plugin is great and avoids the use of php, but it is not dynamic. You need to rebuild each time you want your MT site to integrate new links from the other MT site.

  10. Mark Mascolino

    Jean-Fran

© 2024 dylan tweney

Theme by Anders NorenUp ↑

Discover more from dylan tweney

Subscribe now to keep reading and get access to the full archive.

Continue reading