phpBBSEO / usu

Ultimate SEO URL
32 stars 25 forks source link

Search pagination link incorrect for "fid" parameter after first page #95

Open hbcafe opened 9 years ago

hbcafe commented 9 years ago

To reproduce, search for a term against a specific forum or forums. The search URL will include the fid%5B%5 D= parameter for the first page, but the encoded [] will be stripped off subsequent pages.

Below is a workaround, not a correction. Modify phpbbseo/usu/pagination:

public function generate_page_link($base_url, $on_page, $start_name, $per_page)
{
    // ADD: Workaround problem with "fid" getting mangled.
    if (strpos($base_url, 'search.php') !== false) {
        $base_url = str_replace('fid%5B%5D=', 'fid[]=', $base_url);
    }

This prevents the subsequent code for mangling the fid parameter. Restore it prior to returning:

    // we'll see if start_name has use cases, and we can still work with rewriterules
    $s = ($on_page > 1) ? sprintf($paginated[$base_url], $start_name, ($on_page - 1) * $per_page) : $base_url;

    // ADD: Workaround problem with "fid" getting mangled. 
    if (strpos($base_url, 'search.php') !== false) {
        $s = str_replace('fid[]=', 'fid%5B%5D=', $s);
    }
    return $s;