Fixed vB4 Import: BBCode tags [thread] and [post] should be rewritten to [url]

Steffen

Well-known member
Affected version
2.0.2
XenForo does not support the BBCode tags [thread] and [post]. Both should be rewritten to the URL BBCode.

Something like this in the getPostMessage method should work:
PHP:
$message = preg_replace_callback('#\[(thread|post)\](\d+)\[/\1\]#i', function($m)
{
    $url = $this->app->options()->boardUrl . "/$m[1]s/$m[2]/";
    return '[URL]' . $url . '[/URL]';
}, $message);

$message = preg_replace_callback('#\[(thread|post)=(\d+)\](.*?)\[/\1\]#i', function($m)
{
    $url = $this->app->options()->boardUrl . "/$m[1]s/$m[2]/";
    return "[URL='" . $url . "']{$m[3]}[/URL]";
}, $message);
 
Implemented this change, thank you. Mostly the same as you've done except I think it's safer to use the XF router to build these links properly rather than relying on the board URL, just on the off chance anyone wants to change the routes (and they just so happen to have done it prior to the import) then those links will be correct. Thanks though, good work :)
 
Back
Top Bottom