Steps to reproduce:
Create a view and add a Global: View area to the Header or Footer. Leave the 'Display even if view has no result' checkbox cleared. If you cause the view to have no results (via contextual filters or other filters or just no entities to display), you will see the Global: View area in your rendered output, regardless of the state of the 'Display even if view has no result' checkbox.
This seems to be isolated to Global: View area because on the same view I can add a Global: Text area to the header and when the view returns empty the Global: View area shows while Global: Text area does not.
Also, I know the view is actually empty because <div class="view-empty">
exists in the rendered output. No results behavior shows as well.
Please let me know if you need more information on this bug.
Comment | File | Size | Author |
---|---|---|---|
#17 | hide_header_view_when_no_results-2069185-17.patch | 790 bytes | init90 |
#10 | _patch_hide_header_view_when_no_results-2069185-9.patch | 1.24 KB | lmeurs |
#5 | _patch_hide_header_view_when_no_results-2069185-5.patch | 735 bytes | lmeurs |
Comments
Comment #1
bentobey CreditAttribution: bentobey commentedEncountering this same issue. Anyone have a workaround or fix?
Comment #2
bentobey CreditAttribution: bentobey commentedFor anyone else encountering this issue, the "Views Field View" module can be used as a workaround. The functionality works the same as the built-in View embedding, but properly obeys the "Display even if view has no result" directive.
Comment #3
loparr CreditAttribution: loparr commentedThe problem with Views Field View is that there is no checkbox for "Display even if view has no result" if you put another view inside footer.
Comment #4
cthshabel CreditAttribution: cthshabel commentedI am experiencing the same problem. The checkbox is ignored and nothing is displayed.
Comment #5
lmeurs CreditAttribution: lmeurs commentedI created a patch that hopefully fixes this. It appears Views does not check whether there are results and also ignores the Display even if view has no result setting for the Global: View area.
Inspired by patch from #1217394-81: Change notice: "Display even if view has no result" not working.
Comment #6
vasikei can confirm both the issue and lmeurs's patch (#5) solution.
So i think we have an RTBC here.
Comment #7
eric.chenchao CreditAttribution: eric.chenchao commentedhttps://www.drupal.org/node/1217394
Comment #8
eric.chenchao CreditAttribution: eric.chenchao commentedSorry for updating the status. Change it back now. I have found it is different from https://www.drupal.org/node/1217394
Comment #9
dawehnerDoesn't apply for me :(
The code itself looks though sane.
Comment #10
lmeurs CreditAttribution: lmeurs commentedPatch does not apply since in 7.x-3.x
views_handler_area_view::render()
has been broken up intoviews_handler_area_view::render()
andviews_handler_area_view::loadView()
.See new patch attached.
Comment #11
ashedryden CreditAttribution: ashedryden commentedThe patch on #10 fails at line 52 for me.
Comment #12
lmeurs CreditAttribution: lmeurs commented@ashedryden: Are you using the stable or development version of Views? I just tried the patch on simplytest.me with the current dev version without any problems.
Comment #13
MrPeanut CreditAttribution: MrPeanut commentedPatch from #10 applies cleanly for me on dev. However, I'm still not seeing the footer view on a view that returns empty. (That may be an issue with my view, though.)
Comment #14
ptmkenny CreditAttribution: ptmkenny commented@MrPeanut This patch should cause the footer view to be hidden when the results are empty-- that is the intended behavior.
Marking #10 RTBC based on #12, my own testing, and #6 and #8 (for the previous patch, on which #10 is based).
Comment #15
agudivad CreditAttribution: agudivad commentedFacing same issue in Drupal 8 as well. Please help by providing the patch in Drupal 8.
Comment #17
init90Drupal 8 patch. Maybe worth moving the issue into core tracker?
Comment #18
AswathyAjish CreditAttribution: AswathyAjish commentedI am facing this issue in drupal 9.5.9.
Any solution for this?
Comment #19
DamienMcKennaPlease search for an issue in the Drupal core issue queue for the problem with D9, there might already be an issue for it; this issue is only for the D7 problem.