TXP Hack: preserving MT archive links...
There have been a few documented ways to migrate MT entries to textpattern. One of the issues has been preserving existing links to entries. Here is one way to do it.
[Based on Textpattern 1.0rc1]
- Find a way to preserve the MT entry id in the custom_10 field in the textpattern table.
- You can do this manually using an SQL query, or you could hack the migration script to stash the entry value while it's copying entries over.
- Create a file
archives(archives.phpif you have content negotiation enabled), just like you would for using clean-urls. This file will map the MT-style archives URL to a new textpattern URL.
Contents of archives:
<?php
include "./textpattern/config.php";
include $txpcfg['txpath']."/publish.php";
global $pfr, $url_mode;
if ( preg_match("|archives/(d+).php|", $_SERVER['REQUEST_URI'], $matches) )
{
$id = intval($matches[1]);
$row = safe_row("*", "textpattern", "custom_10 = $id"
;
$url = formatPermLink($row['ID'], $row['Section']);
if ( $url_mode==1 )
$url .= ( $row['url_title'] ? $row['url_title'] : stripSpace($row['Title']) );
header('Location: http://'.$_SERVER['HTTP_HOST'].$url, TRUE, 301);
exit;
}
header("HTTP/1.0 404 Not Found"
;
exit;
?>



