summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-09-10 14:56:43 +0100
committerAlex Pott2015-09-10 14:56:43 +0100
commitd997d39712acff8421d78bc714593a0253d4062c (patch)
treee0b98674b668bba8afd7ec4a114358353bb7cf75
parent997da33d6cce86512646ef10f5b0feefff5f401c (diff)
Issue #2547811 by nlisgo, borisson_, davidhernandez, dawehner, mansspams: Header and footer are appearing in markup when they should be empty
-rw-r--r--core/modules/views/src/Plugin/views/display/DisplayPluginBase.php4
-rw-r--r--core/modules/views/src/Tests/Handler/AreaTest.php35
2 files changed, 38 insertions, 1 deletions
diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
index 09fa129..35e9b92 100644
--- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
+++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
@@ -2217,7 +2217,9 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
public function renderArea($area, $empty = FALSE) {
$return = array();
foreach ($this->getHandlers($area) as $key => $area_handler) {
- $return[$key] = $area_handler->render($empty);
+ if ($area_render = $area_handler->render($empty)) {
+ $return[$key] = $area_render;
+ }
}
return $return;
}
diff --git a/core/modules/views/src/Tests/Handler/AreaTest.php b/core/modules/views/src/Tests/Handler/AreaTest.php
index de41c3d..4f4dda8 100644
--- a/core/modules/views/src/Tests/Handler/AreaTest.php
+++ b/core/modules/views/src/Tests/Handler/AreaTest.php
@@ -116,6 +116,41 @@ class AreaTest extends HandlerTestBase {
}
/**
+ * Tests that the header and footer areas are not rendered if empty.
+ */
+ public function testRenderEmptyHeaderFooter() {
+ $view = Views::getView('test_example_area');
+ $view->initHandlers();
+
+ // Set example empty text.
+ $view->empty['test_example']->options['string'] = '<p>' . $this->randomMachineName() . '</p>';
+
+ $xpath = '//div[contains(@class, :class)]';
+
+ // Verify that the empty header and footer sections have not been rendered.
+ $output = $view->preview();
+ $html = $this->container->get('renderer')->renderRoot($output);
+ $this->setRawContent($html);
+ $this->assertEqual(0, count($this->xpath($xpath, [':class' => 'view-header'])));
+ $this->assertEqual(0, count($this->xpath($xpath, [':class' => 'view-footer'])));
+
+ // Set example header text.
+ $view->header['test_example']->options['string'] = '<p>' . $this->randomMachineName() . '</p>';
+ $view->header['test_example']->options['empty'] = TRUE;
+
+ // Set example footer text.
+ $view->footer['test_example']->options['string'] = '<p>' . $this->randomMachineName() . '</p>';
+ $view->footer['test_example']->options['empty'] = TRUE;
+
+ // Verify that the header and footer sections have been rendered.
+ $output = $view->preview();
+ $html = $this->container->get('renderer')->renderRoot($output);
+ $this->setRawContent($html);
+ $this->assertEqual(1, count($this->xpath($xpath, [':class' => 'view-header'])));
+ $this->assertEqual(1, count($this->xpath($xpath, [':class' => 'view-footer'])));
+ }
+
+ /**
* Tests the access for an area.
*/
public function testAreaAccess() {