« Movable Type Scheduled Tasks | Main | Share This Post in Movable Type 4 »

How to Export Tags from Movable Type 3.3x

Jaclyn asked why she wasn't able to get tags imported to a new MT4 installation. While Movable Type 4 includes an entry's tags in the import specifications, and also exports those tags when saving the data, no prior versions have exported the tags, even though tags have been natively supported since MT 3.3x. Luckily, it's easy to get them.

First, make a backup of ImportExport.pm from your original Movable Type installation, which is the Perl module that handles the export. Do this because you want to make sure that you have a good copy, just in case something goes awry. Put this backup in a safe place, and work with the copy of the file, just in case. Ready? Good.

Using your copy, open ImportExport.pm and locate the line that looks like this:

sub export {

In any version of MT 3.3x (that is, MT 3.31, MT 3.32, MT 3.33, MT 3.34 or MT 3.35), this is on line 516. This indicates the start of the export subroutine. Once you have located this line, scroll down a few lines and locate these lines:

DATE: <$MTEntryDate format="%m/%d/%Y %I:%M:%S %p"$>

This is where you are going to insert the information. Change these two lines so that they look like this:

DATE: <$MTEntryDate format="%m/%d/%Y %I:%M:%S %p"$><MTEntryIfTagged>
TAGS: <MTEntryTags glue=","><$MTTagName quote="1"$></MTEntryTags></MTEntryIfTagged>

What you have done is insert a section of code that will include the tags only if there are tags on the entry. Make sure you include the dashes, as that is a necessary part of the formatting.

By wrapping everything in the MTEntryIfTagged container, you are sure to only include the line if the entry in question has tags. This probably isn't completely necessary, but it makes things tidy, so it's a good idea to include it. The rest of the line just formats everything correctly, producing the necessary information for a valid import.

After making this change, save your changes and exit. Then upload the file to your server and run your export again. Now you should be able to see the tags in your exported file, and you can import these to your MT installation.

There is one difference in this and the MT4 version, and that is that the "include_private" attribute doesn't exist in MT3. This should mean that you get all the tags on the entry, including private tags. But just in case, make a note of any private tags that you have, as you might need to update them later.

This tutorial is written by LMT author Chad Everett of Everitz Consulting.
Tutorial cross posted on Don't Back Down and LMT.

Comments (4)

I have trying these couple days ago, but I wasn’t able to see the tags in exported file. Now I can. Thanks

@Aleks -

Great! I'm glad that you were able to get the tags out correctly.

Sam Potts:

Hi all,

Thank you for this tip, Chad! Saved my butt.

Just an FYI:

I am exporting entries from one blog in a 3.33 installation into another blog in the same installation. Same server, etc. TypeMover is not working for me so I am manually cloning a blog.

I could not import tags using the exact code that you provide, but moving the <MTEntryIfTagged> tag AFTER "TAGS:" allowed me to import back into 3.33.

This code works as described above, but with that one tag moved:

DATE: <$MTEntryDate format="%m/%d/%Y %I:%M:%S %p"$>
TAGS: <MTEntryIfTagged><MTEntryTags glue=","><$MTTagName quote="1"$></MTEntryTags></MTEntryIfTagged>

I take no credit -- it's all Chad's work.


Hi Sam -

Thanks for the note. It could be that if you have it prior to the TAGS: indicator, it means that sometimes you will have the tags and sometimes not, which screws up the importer. All of my entries (when I was testing) had tags - but if yours don't, this might not be the case.

So in this case, it's not a bad idea - the only difference is that if you have an entry without, you'll get an empty TAGS: line, without any tags following.

That's not bad - and in fact, you can leave it out entirely if you like, because the same thing will show up (there just won't be any tags listed).

Still, glad that you got it to work!

Post a comment

(If you haven't left a comment here before, your comment may need to be approved before will appear on the entry. Thanks for waiting.)