Entry Location Plugin for Movable Type

Overview

This MovableType plugin allows you to tag each individual post with a location. 
For instance, your posts might say:

Posted by yuri at December 20, 2003 12:53 AM from Madison, WI | TrackBack

The plugin will also add the necessary metatags to make your page ready to be indexed by geourl

This is different from some of the other location plugins that I have seen in that it allows you to tag each individual entry, rather than just including your current location on the sidebar.

In order to get this working, you will need to do four things:

  1. Install the plugin, which should be trivial
  2. Create matching location codes to descriptions and (optionally) to GeoURL coordinates
  3. Modify your MT templates to add the new tags provided by the plugin
  4. Enter location codes into your "keywords" field of the post to tag the post with a location

Getting the Code

The code for the plugin is here. Save the code into a file in your "plugins" directory.  You can call the file "mt-location.pl" but it doesn't really matter, as long as it has a ".pl" extension.  This should really be just that simple.  If this doesn't work, email me (see the bottom of the page).

Setting up a location file

You now need to create a file that will define location codes that you want to use.  It should be a tab-delimited file with four fields:

  1. location code
  2. place name
  3. latitude
  4. longitude

Each location code must start with "loc_".  This is necessary to distinguish them from other keywords you might want to use.  The place name can be anything you want.  It can be "Madison, WI", "Home", "The Pad", "Office", etc.  The important point is that this is what your visitors are going to see on your webpage.

Latitude and longitude coordinates are optional.  If you don't want to enter them (either because you don't want to look them up or because you don't want to reveal the actual location), put zeros.

My location file looks like this:

loc_madison Madison, WI 43.0723 -89.4253
loc_berk Berkeley, CA 37.8695 -122.2704
loc_sims South Hall, Berkeley, CA 37.8701 -122.2581
loc_pa Palo Alto, CA 37.4404 -122.1563
loc_ec El Cerrito, CA 37.9025 -122.2979

But it could be:

loc_berk Berkeley, CA 37.8695 -122.2704
loc_sims Office 0 0
loc_pa Geekland, CA 37.4404 -122.1563
loc_ec Home 0 0

If you do want to include the coordinates, I recommend using maporama.com to obtain them.

When including the coordinates, you might want to think about how precise you want to make them.  As a rule of thumb, 1 degree latitude is about 100 km (or 60 mi), so:

If you want precision of up to your geocoordinates would be (if you were in Berkeley, CA):
10 meter (30 feet)
37.8695 and -122.2704
100 meters (300 feet)
37.870 and -122.270
1 km (.3 mi)
37.87 and -122.27
10 km (3 mi)
37.9 and -122.3
100 km (30 mi)
38 and -122


Editing the Templates

 You should now edit your MT templates to make use of the three new tags that the plugin provides you with: <MTLocation/>, <MTIfLocation/> and <MTLocationMetaTags/>.

The first two tags are used to add the "posted from Berkeley, CA" text to both the index pages and the individual entry page.  <MTLocation/> is what will get replaced with your location name.  <MTIfLocation>...</MTIfLocation> can be used to make sure that pronouns like "from" are not included for entries not tagged with location.

Here is what I currently have for my main index page:

<div class="posted">
 Posted at <$MTEntryDate format="%X"$>
 <MTIfLocation> from <MTLocation geourl="1"/> </MTIfLocation>
 ...
</div>

Note that <MTLocation> has an extra "geourl" attribute that specifies whether you want the location name to be a link to the geourl page listing other cites near you. 

You should also add <MTLocationMetaTags/> tag into the <head> section of your Individual Entry Archive template.  (Do not put them into the index templates.  This tag will get replaced with something like:

<meta name='ICBM' content='43.0723, -89.4253'>
<meta name='DC.title' content='Location Plugin for Movable Type'>

The DC.title field will be taken from the entry title. The <head> section of my individual entry archive template currently looks as follows:

<head>
 <meta http-equiv="Content-Type" content="text/html; charset=<$MTPublishCharset$>" />
 <MTLocationMetaTags/>
 <title><$MTBlogName$>: <$MTEntryTitle$></title>
 <link rel="stylesheet" href="<$MTBlogURL$>styles-site.css" type="text/css" />

 ...

Tagging your Entries

Finally, you can start tagging your entries with location by simply entering the location codes as keywords.  (If your post template does not have a "keywords" field, you need to customize it, but it should be there by default.)

Questions of Suggestions?

Email me at yuri@{domain-of-this-webpage} if you have questions or suggestions.