Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart search without filter does not work as expected after searching with filter #42917

Open
pixelhexe opened this issue Feb 28, 2024 · 1 comment

Comments

@pixelhexe
Copy link

Steps to reproduce the issue

  1. Backend: Create a search filter (e.g. search only articles in specific categories)
  2. Create a search menu item with this search filter
  3. Create a second search menu item without this search filter (because you need these two search possibilities on different parts of your website)
  4. Frontend: Search with menu item without search filter - results are ok
  5. Search with menu item with search filter - results are ok
  6. Search again with menu item without search filter - results are not ok because the search filter ID is still in the query string of the results URL ("...?q=your-search-word&f=1").

Expected result

Search results should always work without filter if no filter is assigned to the menu item.

Actual result

Search results do not work without filter if you did another search with filter previously.

System information (as much as possible)

Joomla 4.4.3, PHP 8.1

Additional comments

A fix would be to delete the "f" variable in the query string if no filter is assigned to the search menu item:

components\com_finder\src\Helper\RouteHelper.php

public static function getSearchRoute($f = null, $q = null) {
...
// Add the pre-defined search filter if present.
if ($f !== null) {
$uri->setVar('f', $f);
}
// MY CODE ADDITION
else {
$uri->delVar('f');
}
// END OF MY CODE ADDITION
...
}

@Hackwar
Copy link
Member

Hackwar commented Sep 14, 2024

Please check if this is solved in joomla 5 and maybe also with #44055.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants