Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I added a block to a region using page manager UI, this block in some pages rendered with this layout has content and in others not, depending of that on my twig template I decide if I render this region with S css class or Y css class. But the regions is coming is always not empty no matters if the only block is empty or not. I checked the panels code and I found
https://cgit.drupalcode.org/panels/tree/src/Plugin/DisplayBuilder/Standa...
protected function buildRegions(array $regions, array $contexts) {
$build = [];
foreach ($regions as $region => $blocks) {
if (!$blocks) {
continue;
}
$region_name = Html::getClass("block-region-$region");
$build[$region]['#prefix'] = '<div class="' . $region_name . '">';
$build[$region]['#suffix'] = '</div>';
this method ALWAYS add the wrapper no matters if is added or not any content to the region.
Comment | File | Size | Author |
---|---|---|---|
#5 | test-passed.jpg | 516.04 KB | meickol |
#2 | region-wrappers-not-always-added-2970834-1.patch | 1.15 KB | meickol |
Comments
Comment #2
meickolI create this patch, with this the method add the wrappers only if the region has content to show.
Comment #4
meickolComment #5
meickolI need help with this I ran the test on my local and all test passed , see screenshot attached
Why the test are no passing here ? thanks.
Comment #6
meickolComment #7
tim.plunkettThis is a core bug, see #953034: [meta] Themes improperly check renderable arrays when determining visibility.
Also, this is a duplicate of #2741345: How to conditionally print (or not) panels layout content based on content or empty content
Comment #8
tim.plunkettRegardless of that issue this might be a good standalone fix
Comment #9
manuel.adanPHP 5.5 & MySQL 5.5, D8.4 13 pass,8 fail
Drupal 8.4 is unsupported, so I retest #2 and now it pass with no additional changes:
I launched some additional tests along with page_manager that also pass.
Comment #10
manuel.adanComment #11
manuel.adanAnyway, what is the point of this wrapper? I also simply removed it and tests still pass.