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}.

  • Alas - my solution appears to fall down when the template route variables are named.

    Derek Hogue
    06th December, 2014 at 11:33am
  • This seems more reliable (though if you had another md5 string in your URL, it’s trouble):

    preg_match('/[a-f0-9]{32}/', ee()->uri->query_string, $matches);
     $search_id = $matches[0];
    Derek Hogue
    06th December, 2014 at 11:45am
  • 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]);


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

ExpressionEngine News!

#eecms, #events, #releases