This is old content! The graveyard is a snapshot of content created from 2002-2005. For new stuff, visit Maniacal Rage.
 

Easy Friend Links

posted on march 4, 2003, tag: movable type

Note: This is really outdated and I don't suggest you use it. It can slow down MT quite a bit.

I've received plenty of requests lately to write a quick tutorial on how I use MTMacros to automate common friend links on this site. For instance: Shawn Morrison, a complete link to Shawn's website, is created by simply typing shawnmorrison in the MT entry textarea. Simple and efficient.

This is based on the tutorial I wrote before, called MT Macros & Acronyms (which has been updated, by the way, to be more efficient), but only in principal. You can use this tutorial completely separate from that one, or vice versa.

Like in the other tutorial, you're gonna need two plugins first:

     » MTPerlScript
     » MTMacro

Once these are installed, you're ready to move on. This is a little bit tricky, so try to stay with me. There are two things you'll need to edit, and they might seem confusing, but so long as you follow the style of the example, you'll be just fine.

Create a new Template Module. Do this in your MT Admin area, in the Templates section. Scroll down the bottom and click the link to create a new module.

In the Template Name field, type "friends" (minus the quotes) and in the module body textarea, copy and paste the code from this text file. But you're gonna need to edit the links in there, so it contains your friends.

There are two places to edit. The first is near the top, and by default, looks like this:

%friends = (
     "garrettmurray"   => "Garrett",
     "garrettmurrays"  => "Garrett’s",
     "shawnmorrison"   => "Shawn",
     "shawnmorrisons"  => "Shawn’s"
     );

This is an associative array. Its keys (the values to the left of =>) are what you're gonna type into your MT entries and its values (to the right =>) are the names that will output on the website. You'll also notice there are two of each. The second is the same, but contains an 's' on the left side and a ’s on the right side. This second entry for each is for instances when you want to link someone in an ownership form (example: stevenellisons blog is called Blind Spot). When adding your items to this array, be sure to place a comma at the end of each line, except for the last one, as seen in the example.

The second area you'll need to edit looks like this by default (ignore the screwy spacing here):

"garrettmurray" friendlink href "http://www.maniacalrage.net" title "ManiacalRage"
"garrettmurrays" friendlink href "http://www.maniacalrage.net" title "ManiacalRage"
"shawnmorrison" friendlink href "http://www.morrisonfilm.com" title "MorrisonFilm"
"shawnmorrisons" friendlink href "http://www.morrisonfilm.com" title "MorrisonFilm"

Now what you have to is edit each of these two areas and add your own links. Just follow the style I've set up here. It should be pretty easy. Once you've added all your links, save this template module.

One last step. You need to include this in your site. At the top of every file you want this to work, you'll need to add: <$MTInclude module="friends"$> and then you'll need to turn macros on for your content by either wrapping everything in <MTMacroApply> and </MTMacroApply> or by adding apply_macros="1" to each tag (like MTEntryBody, etc).

Hope this all made sense, and that others can use this little trick to make their blogging a little easier.

Comments

There are 3 comments, comments are closed

Shawn on 03/05/2003:

Very very nice. Just implimented it and all seems to be smooth. Now I can't wait to write a new entry and link to you. And I also am wondering what other functions these macros could perform... something we (you) haven't thought of yet?

Garrett on 03/06/2003:

It seems like most people have been able to get this working. I was a little worried because of the array and such, and sometimes it feels like I'm not explaining things as well as I could.

I'm glad it's working for you... it should make your life a lot easier. As far as more things go, I've been thinking about it. I'm not sure yet. There is a lot of power to be harnessed here, though, so if I come up with anything I'll let you know.

kassie on 12/02/2003:

Wow I'm impressed, not surprised but very impressed.


See Also

View the archive

Original iPod Introduction
How far we've come in just a few short years. Here's where it all started.

Front Row on Non-iMacs
Going to try this tonight!

WriAShorStorWe!
DY starts a one-week short story writing event for people to lazy to enty NaNoWriMo. VerCooIdea.

Lost Rhapsody
Funny Flash movie using Weird Al music and Lost stuff. Lyrics make a surprising amount of sense!

Jed's Other Poem
Unsolicited music video made on an Apple ][. Fantastic!

Printers Output Secret Barcode
The government is keeping tabs on what you print, with the help of major printer companies.

Dreamhost Promo Codes
DH already has very cheap, very good hosting—this just sweetens the deal.

Photos of the new iPod
Just received my new iPod and I put a few photos up.

PEZ MP3 Player
Funny idea that actually looks kind of neat. I like that it comes pre-loaded with "indie" music.

HD Easter Egg
"My Name is Earl" on NBC gives viewers with HD TVs a little easter egg. Cute, but weird.