diff --git a/src/Plugin/TabType/ViewContent.php b/src/Plugin/TabType/ViewContent.php index 35072c8..a78db86 100644 --- a/src/Plugin/TabType/ViewContent.php +++ b/src/Plugin/TabType/ViewContent.php @@ -79,7 +79,33 @@ class ViewContent extends TabTypeBase { return []; } - $render = $view->buildRenderable($options['display'], $args); + // Return empty if the view is empty. + $view_results = views_get_view_result($options['vid'], $options['display']); + if (!$view_results && !empty($options['vid']) && !empty($options['display'])) { + // if the initial view is empty, check the attachments + $view = Views::getView($options['vid']); + $view->setDisplay($options['display']); + $display = $view->getDisplay(); + $attachments = $display->getAttachedDisplays(); + + // If there are attachments, check if they are empty. + if (!empty($attachments)) { + foreach ($attachments as $attachment) { + if (!empty(views_get_view_result($options['vid'], $attachment))) { + $view_results = TRUE; + continue; + } + } + } + } + + if (empty($view_results)) { + return []; + } + + else { + $render = $view->buildRenderable($options['display'], $args); + } // Set additional cache keys that depend on the arguments provided for this // view.