I Have a display mode that renders out two optional fields in the sidebar, via a Display mode called 'Content sidebar', this is done using a 'Entity view (Content:[node type])' block.
This Block is set to only display on a single content type however when viewing that content type the region is rendered even when the display mode to get rendered in the sidebar region has zero content content.
Rendered aside:
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'region' -->
<!-- FILE NAME SUGGESTIONS:
* region--sidebar-second--entity--node--canonical.html.twig
* region--sidebar-second.html.twig
x region.html.twig
-->
<!-- BEGIN OUTPUT from 'profiles/council/themes/custom/custom_theme/templates/layout/region.html.twig' -->
<div class="region region-sidebar-second">
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'block' -->
<!-- FILE NAME SUGGESTIONS:
* block--entityviewcontent-sidebar.html.twig
* block--entity-view--node.html.twig
* block--entity-view.html.twig
* block--ctools.html.twig
x block.html.twig
-->
<!-- BEGIN OUTPUT from 'core/themes/classy/templates/block/block.html.twig' -->
<div id="block-entityviewcontent-sidebar" class="contextual-region block block-ctools block-entity-viewnode">
<div data-contextual-id="block:block=entityviewcontent_sidebar:langcode=en" class="contextual" role="form"><button class="trigger visually-hidden focusable" type="button" aria-pressed="false">Open configuration options</button>
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'links__contextual' -->
<!-- FILE NAME SUGGESTIONS:
* links--contextual.html.twig
x links.html.twig
-->
<!-- BEGIN OUTPUT from 'core/themes/classy/templates/navigation/links.html.twig' -->
<ul class="contextual-links" hidden="">
<li class="block-configure"><a href="/admin/structure/block/manage/entityviewcontent_sidebar?destination=node/53">Configure block</a></li>
</ul>
<!-- END OUTPUT from 'core/themes/classy/templates/navigation/links.html.twig' -->
</div>
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'ds_entity_view' -->
<!-- BEGIN OUTPUT from 'modules/contrib/ds/templates/ds-entity-view.html.twig' -->
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'ds_reset' -->
<!-- FILE NAME SUGGESTIONS:
* ds-reset--node--53.html.twig
* ds-reset--node-news-sidebar-second.html.twig
* ds-reset--node-news.html.twig
x ds-reset--node-sidebar-second.html.twig
* ds-reset--node.html.twig
* ds-reset.html.twig
-->
<!-- BEGIN OUTPUT from 'profiles/council/themes/custom/custom_theme/templates/ds-reset--node-sidebar-second.html.twig' -->
<div class="l-container">
</div>
<!-- END OUTPUT from 'profiles/council/themes/custom/custom_theme/templates/ds-reset--node-sidebar-second.html.twig' -->
<!-- END OUTPUT from 'modules/contrib/ds/templates/ds-entity-view.html.twig' -->
</div>
<!-- END OUTPUT from 'core/themes/classy/templates/block/block.html.twig' -->
</div>
<!-- END OUTPUT from 'profiles/council/themes/custom/custom_theme/templates/layout/region.html.twig' -->
Is there a way to only render out something if content would be visibly displayed by the block?
Comments
Comment #2
realityloop commentedComment #3
realityloop commentedComment #4
vaccinemedia commented@realityloop you say this is a duplicate but have not referenced the duplicate issue
Comment #5
jumoke commentedI am having this issue as well, where is the duplicate?
Comment #6
weseze commentedI'm also unable to find the actual duplicate issue, so setting back to active.
Comment #7
ecvandenberg commentedThis is already an old issue. I find this rendering of empty entities very annoying behavior. Are we alone out there? Are we missing something?
Does anyone know more about how to deal with this?
Comment #8
yakoveka commentedHere is the duplicate, but it's not fixed yet: https://www.drupal.org/project/drupal/issues/953034
Comment #9
avpaderno#953034: [meta] Themes improperly check renderable arrays when determining visibility is about themes, while this issue is about entity views. I am not sure that fixing that issue would fix this issue too.