Bug #20680 Version Retired

Search results template does work with template routes

Version: 2.9.2 Reporter: Derek Hogue

This is an archived bug report. If you are experiencing a similar issue, upgrade to the latest release and if that does not solve the problem, submit a new bug report

When using a template route (rather than a template path) as the “result_page” parameter of a search form, the result page returns “The action you have requested is invalid” error.

Looking at the search module code, the cached search query is fetched by looking at ee()->uri->query_string, which in the case of a template route is the entire series of segments, rather only the last segment, so the search module is looking up the cached query based on the first segment (i.e. “search”, or whatever your template route specifies), rather than the search ID hash.

This also affects {exp:search:keywords}.

  • In mod.search.php, change all instances of:

    $search_id = substr(ee()->uri->query_string, 0, 32);

    And also:

    $qstring = explode('/', ee()->uri->query_string);
    $search_id = trim($qstring[0]);

    To:

    if(!empty(ee()->TMPL->template_route_vars))
    {
     $search_id = substr(end(ee()->TMPL->template_route_vars), 0, 32);
    }
    else
    {
     $search_id = substr(ee()->uri->query_string, 0, 32); 
    }
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases