Topic Links 2.2: Archive Fix

If you no longer run PHP on your server but have a static HTML export of the archive, or if you prefer not to modify core files, use URL rewriting.

Create or edit .htaccess in your archive/ directory:

RewriteEngine On
RewriteBase /forum/archive/

  • If duplicates persist:
  • If performance issues appear on large sites:
  • We didn't have the source code for the original 2.2 parser. But we had 12,000 archived HTML files and a SQL dump of the original topic map. Here is the fix we built.

    This update fixes archive-related issues in Topic Links 2.2: it restores correct archive linking behavior, improves compatibility with common archive permalink structures, and prevents duplicate entries when generating link lists for archived posts. Topic Links 2.2 Archive Fix

    This patch modifies the archive/global.php and archive/index.php files.

    Backup first: Always create backups of your archive directory.

    Step 1: Edit archive/global.php

    Find the function construct_archive_link (around line 120). Original code often looks like:

    function construct_archive_link($threadid)
    return "index.php/t-".$threadid.".html";
    

    Replace it with:

    function construct_archive_link($threadid)
    global $vboptions;
        // Fix for double extension and malformed links
        $link = "index.php/t-" . intval($threadid);
        if ($vboptions['archiveext'] == '.html') 
            $link .= ".html";
    return $link;
    

    Step 2: Edit archive/index.php

    Find the line that parses the PATH_INFO or QUERY_STRING (usually near line 45). Look for:

    $threadid = intval(substr($QUERY_STRING, 2));
    

    Change it to:

    // Topic Links 2.2 Archive Fix - Improved parsing
    $path = getenv('PATH_INFO');
    if ($path && preg_match('#/t-([0-9]+)(\.html)?#i', $path, $matches)) 
        $threadid = intval($matches[1]);
     else 
        $threadid = intval(substr($QUERY_STRING, 2));
    

    Step 3: Save and Test

    Upload the modified files, clear your browser cache, and test a topic link. It should now resolve correctly.