Problem/Motivation
The current implementation only checks if results are empty and if they are, the view is hidden.
This is sadly incorrect and prevents this module from working with (required) exposed filters! The check has to be extended to check if there are exposed filters. In that case the view may not be hidden but instead shown with the form.
A typical use case would be if the required exposed filter option / better exposed filters is used in views or if the view returns empty results for a prefilled search.
Currently the module is unusable in that case.
Steps to reproduce
- Create a view with exposed filters
- Reference it via viewsreference
- Set "Advanced: Exposed Form" to "Input required" (admin/structure/views/nojs/display/EXAMPLEVIEW/default/exposed_form)
- Result: View is always hidden in viewsreference
Workaround
As a dirty workaround you can add a placeholder text in "Empty results behaviour" area. Then the view is shown, but of course that's no valid solution and until you find this workaround you've lost hours. :)
Proposed resolution
- Add check to hide the view if results are empty and there are no exposed filters
- Optionally add an option "Hide empty view" which is enabled by default for maximum flexibility.
Remaining tasks
Discuss
Implement
Test
Release
User interface changes
API changes
Data model changes
Issue fork viewsreference-3195386
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
anybodyComment #4
anybodyThe given MR should fix the issue. Anyway it would make sense if someone could check why the existing check
is not enough. PERHAPS that might be an upstream issue. But even if, the given patch should not make things worse.
Please review. For us this patch fixes the described issue.
If someone needs the patch until this is fixed, this is the URL:
https://git.drupalcode.org/project/viewsreference/-/merge_requests/3.patch
Comment #5
anybodyComment #7
seanbMakes sense. Thanks.
Comment #8
anybodyThank you very much @seanB :)