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

Filter news by categories with multiple select fields #2495

Open
kanow opened this issue Jun 18, 2024 · 1 comment
Open

Filter news by categories with multiple select fields #2495

kanow opened this issue Jun 18, 2024 · 1 comment

Comments

@kanow
Copy link
Contributor

kanow commented Jun 18, 2024

Bug Report

Current Behavior
I'm adding a news plugin with no category restriction, to show all news from a sysfolder.
In fluid template I built two select fields for categories.
If I select only one category in the first select field, te result is empty. If I select categories in both of the select fields, then the result is not empty. It shows news data with selected categpories due to the category conjunction "and". The reason for that is an empty second category in demand object

categories => protected array(2 items)
         0 => '39' (2 chars)
         1 => '' (0 chars)

If I change categoryConjunction to "or" it works. But thats not what I want. I need categoryConjunction to "and" for the two categories to get the expected result.

Expected behavior/output
Get the news with the selected category in the search result also if only one select field was used to select a category.

Environment

  • TYPO3 version(s): 12.4.14
  • news version: 11.4.2
  • Is your TYPO3 installation set up with Composer (Composer Mode): yes
  • OS: Local docker environment with PHP 8.2

Possible Solution
Use array_filter to remove empty values
Add this line after line 205 in NewsController in the overwriteDemandObject method.

$propertyValue = is_array($propertyValue) ? array_filter($propertyValue) : $propertyValue;

Maybe array_filter is not the best solution, not sure.

@georgringer
Copy link
Owner

maybe use explode + GeneralUtility::intExplode(',', $array, true)

kanow added a commit to undkonsorten/news that referenced this issue Jun 18, 2024
kanow added a commit to undkonsorten/news that referenced this issue Jun 19, 2024
kanow added a commit to undkonsorten/news that referenced this issue Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants