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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bentobey’s picture

Encountering this same issue. Anyone have a workaround or fix?

bentobey’s picture

Issue summary: View changes

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

loparr’s picture

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

cthshabel’s picture

I am experiencing the same problem. The checkbox is ignored and nothing is displayed.

lmeurs’s picture

Version: 7.x-3.7 » 7.x-3.x-dev
Status: Active » Needs review
FileSize
735 bytes

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

vasike’s picture

Status: Needs review » Reviewed & tested by the community

i can confirm both the issue and lmeurs's patch (#5) solution.
So i think we have an RTBC here.

eric.chenchao’s picture

Status: Reviewed & tested by the community » Closed (duplicate)
eric.chenchao’s picture

Status: Closed (duplicate) » Reviewed & tested by the community

Sorry for updating the status. Change it back now. I have found it is different from https://www.drupal.org/node/1217394

dawehner’s picture

Status: Reviewed & tested by the community » Needs work

Doesn't apply for me :(

error: patch failed: handlers/views_handler_area_view.inc:69
Falling back to three-way merge...
Applied patch to 'handlers/views_handler_area_view.in

The code itself looks though sane.

lmeurs’s picture

Patch does not apply since in 7.x-3.x views_handler_area_view::render() has been broken up into views_handler_area_view::render() and views_handler_area_view::loadView().

See new patch attached.

ashedryden’s picture

The patch on #10 fails at line 52 for me.

***************
*** 52,62 ****
     */
    function render($empty = FALSE) {
      if ($view = $this->loadView()) {
-       if (!empty($this->options['inherit_arguments']) && !empty($this->view->args)) {
-         return $view->preview(NULL, $this->view->args);
-       }
-       else {
-         return $view->preview(NULL);
        }
      }
      return '';
--- 52,64 ----
     */
    function render($empty = FALSE) {
      if ($view = $this->loadView()) {
+       if (!$empty || $this->options['empty']) {
+         if (!empty($this->options['inherit_arguments']) && !empty($this->view->args)) {
+           return $view->preview(NULL, $this->view->args);
+         }
+         else {
+           return $view->preview(NULL);
:
***************
lmeurs’s picture

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

MrPeanut’s picture

Patch 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.)

ptmkenny’s picture

Status: Needs review » Reviewed & tested by the community

@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).

agudivad’s picture

Facing same issue in Drupal 8 as well. Please help by providing the patch in Drupal 8.

Status: Reviewed & tested by the community » Needs work
init90’s picture

Status: Needs work » Needs review
FileSize
790 bytes

Drupal 8 patch. Maybe worth moving the issue into core tracker?

AswathyAjish’s picture

I am facing this issue in drupal 9.5.9.

Any solution for this?

DamienMcKenna’s picture

Status: Needs review » Needs work

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