Change Basename Length for Existing Movable Type Entries

| No Comments

Changing the length of the Basename in Movable Type's settings will change the Basename length for new entries. The Basename for existing entries will not change.

I tried using Brad Choate's EntrySetBasename plugin (which was written for MT4.x) to change the Basename for all existing entries, but the plugin would not install without an error in the Movable Type 5 admin interface - and MT would not work with the plugin installed.

I wanted all blog entries to have up to the maximum of 250 characters for the Basename length, and I was willing to delete, if necessary, all entries (about 775) and import them with new Basenames. So, these are the steps I took (I am not responsible for any problems you may encounter. Backup all files first.):

  1. Export all blog entries to a backup file (important in case you mess up)
  2. Back up the source blog to a backup file (same reason)
  3. Create an index template in the format used for MT entry export files
  4. Change the Basename field in the template to the EntryTItle but with hyphens removed and dirify-ed with spaces changed to underscores
    • change:
    • to:
      BASENAME: <$mt:EntryTitle regex_replace="/-/g","" dirify="_" trim_to="250"$>
  5. Set an Output File for the template
  6. Publish the template to generate the output file (which is an export file of all entries with a maximum 250-character Basename)
  7. Copy the output file into the mt/import/ directory
  8. Delete all entries from the blog
  9. Import the output file that is now in the mt/import directory
  10. After the import finished, remove the output file from the mt/import directory (important so you don't import the entries again by mistake)
  11. Check to make sure entries with long EntryTitles also have long Basenames - and they do!

The export template format I used is below.

<mt:Entries lastn="99999">AUTHOR: <$mt:EntryAuthor strip_linefeeds="1"$>
TITLE: <$mt:EntryTitle strip_linefeeds="1"$>
BASENAME: <$mt:EntryTitle regex_replace="/-/g","" dirify="_" trim_to="250"$>
STATUS: <$mt:EntryStatus strip_linefeeds="1"$>
ALLOW COMMENTS: <$mt:EntryFlag flag="allow_comments"$>
CONVERT BREAKS: <$mt:EntryFlag flag="convert_breaks"$>
ALLOW PINGS: <$mt:EntryFlag flag="allow_pings"$>
<mt:IfNonEmpty tag="MTEntryCategory">PRIMARY CATEGORY: <$mt:EntryCategory$></mt:IfNonEmpty>
<mt:EntryCategories>CATEGORY: <$mt:CategoryLabel$></mt:EntryCategories>
DATE: <$mt:EntryDate format="%m/%d/%Y %I:%M:%S %p"$>
<MTEntryIfTagged include_private="1">TAGS: <MTEntryTags include_private="1" glue=","><$MTTagName quote="1"$></MTEntryTags></MTEntryIfTagged>
<$mt:EntryBody convert_breaks="0"$>
<$mt:EntryMore convert_breaks="0"$>
<$mt:EntryExcerpt no_generate="1" convert_breaks="0"$>
AUTHOR: <$mt:CommentAuthor strip_linefeeds="1"$>
EMAIL: <$mt:CommentEmail strip_linefeeds="1"$>
IP: <$mt:CommentIP strip_linefeeds="1"$>
URL: <$mt:CommentURL strip_linefeeds="1"$>
DATE: <$mt:CommentDate format="%m/%d/%Y %I:%M:%S %p"$>
<$mt:CommentBody convert_breaks="0"$>
TITLE: <$mt:PingTitle strip_linefeeds="1"$>
URL: <$mt:PingURL strip_linefeeds="1"$>
IP: <$mt:PingIP strip_linefeeds="1"$>
BLOG NAME: <$mt:PingBlogName strip_linefeeds="1"$>
DATE: <$mt:PingDate format="%m/%d/%Y %I:%M:%S %p"$>

Leave a comment

January 2017

Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Creative Commons License
This blog is licensed under a Creative Commons License.
Powered by Movable Type 5.2.2

About this Entry

This page contains a single entry by Cheryl published on April 23, 2011 11:16 AM.

Stylesheet for MT5 theme not working was the previous entry in this blog.

Maya and Mia came home is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.