If I assign a block to a sidebar region and specify it to only appear on a specific page (/contact);

The block is correctly rendered in the sidebar, but there is now an empty div rendered in the sidebar on all other pages too; showing an empty sidebar and pushing the content to the middle in the whole website.

I think the sidebar regions should not be rendered if there are no blocks assigned to it.

I've tried {% if content|render %} in region.html.twig and page.html.twig, but that didn't do the trick.

Any idea how to fix this? Much appreciated.

Comments

yazzybe created an issue. See original summary.

yazzbe’s picture

Issue summary: View changes
Richard Buchanan’s picture

Status: Active » Postponed (maintainer needs more info)
StatusFileSize
new178.32 KB
new123.7 KB
new394.81 KB

I tried to duplicate the issue, but it's not appearing on my end. I assigned blocks to both sidebars and restricted to certain pages, but no empty sidebar elements are rendered.

Which block and to which sidebar region was it assigned? The default block--sidebar-first.html.twig, block--sidebar-second.html.twig and region.html.twig templates all use {% if content %} before printing any elements. The same for page.html.twig, which uses {% if page.sidebar_first %} and {% if page.sidebar_second before rendering the sidebars.

Are you using a sub-theme and overriding any of these templates? If so, could you copy and paste the code for the page, block and region templates?

I've attached screenshots to show the block layout page, configuration of block to restrict to certain pages, and the front page to show no sidebars are being rendered. Using the default page.html.twig UIkit template would place the sidebars in an <aside> element as a sibling to the <main> element highlighted in the front.png screenshot.

yazzbe’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

You are right. Works as designed.

The subtheme I was testing with was created in an (much) older version of uikit 8.3.x. I removed that one and drushed a new one.

dudeweb’s picture

composer subtheme my_theme does not work!!

[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "subtheme" is not defined.