I have bootstrap theme installed in my site. I have two sidebar blocks displaying only in home page. Inner pages just content region displaying. But the issue is though there is no sidebar block the contant region not expanding to full width. I checked the page.html.twig file there the below conditions is given -
{%
set content_classes = [
page.sidebar_first and page.sidebar_second ? 'col-sm-6',
page.sidebar_first and page.sidebar_second is empty ? 'col-sm-9',
page.sidebar_second and page.sidebar_first is empty ? 'col-sm-9',
page.sidebar_first is empty and page.sidebar_second is empty ? 'col-sm-12'
]
%}
and in sidebar section
{# Sidebar Second #}
{% if page.sidebar_second %}
{% block sidebar_second %}
{{ page.sidebar_second }}
{% endblock %}
{% endif %}
When I see the page source I can see the
I expect the to hide.
Can anyone tell what is the issue?
Thanks in advance.
Comments
Comment #2
markhalliwellThis is a core issue. Don't ask me to explain it, it's too complicated. Read all the comments in the related issue (especially closer to the end).
Comment #3
ressaI found a post with a proposed solution. I tried the concept out in the Bootstrap page.html.twig file, and it seems to work.
Current Bootstrap page.html.twig file, around line 131:
With added checks, to see if the regions are empty or not:
It looks clunky, but an empty sidebar_second is no longer printed out.
Comment #4
ressaSimilarly, if you don't want to show empty blocks, update block.html.twig:
Comment #5
markhalliwellYou cannot use the
striptagsTwig filter as it would strip out all valid HTML that's in the content as well, if it isn't actually empty.Like I said, this is a core bug... one that is very complex and complicated.
Comment #6
ressaThanks for commenting. What do you do, to avoid printing out empty regions and blocks?
Comment #7
markhalliwellNothing.... that's why it's a major core bug.
Comment #8
hkirsman commentedAs @markcarver warned, I used this method and now debugged it for a day to find why my block is not visible:
<drupal-render-placeholder callback="Drupal\block\BlockViewBuilder::lazyBuilder" arguments="0=eventregistrationform&1=full&2" token="afb5cea2"></drupal-render-placeholder>I was expecting the region to have actual html in it but Drupal switches from html to placeholders according to whatever the internal mechanics are.
Comment #9
marcel tuchek commented3 years ago and that bug still isn't fixed? Or have I missed something?
Comment #10
wotney commentedFollowing
Comment #11
thalemn commentedFollowing
Comment #12
ressaJust a tip to @wotney and @thalemn: You can click the "Follow - 10 Followers" link on the right hand side to subscribe to an issue.