I have created a region--footer.html.twig
template which only contains the static markup for the footer. Now I would like to render this region at the bottom of each page so I have added the following to the end of page.html.twig
:
{{ page.footer }}
This works fine as long as I have connected a block to the footer region under admin/structure/block
. If no blocks are placed in the region it is regardes as empty and is not rendered. How can I change so the region--footer.html.twig
is used even if there is no blocks placed in the region?
I was thinking of using a preprocess function for the region doing something like this:
function template_preprocess_region(&$variables) {
if ($variables['region'] == 'footer') {
$variables['content'] = 1;
}
}
<ul>
if it's not going to contain any<li>
s, same deal with regions and blocks. Regions only exist to house blocks, so a region without blocks serves no purpose and shouldn't render. The obvious solution would be to create a block for your static footer, then you can put it in a region and control visibility in the standard fashionpage.html.twig
by adding a specific region file with static html. The region template is not empty it conains all the markup for the actual footer - just not any connected blocks. So this can not be done - should not be done?