Comments

mudd’s picture

EDIT: I've learned a lot since I started this thread, so clarifying the issue.
Problem/Motivation

I need to be able add a custom region and then not render it. AT uses a page-layout.markup.yml (I'm not sure if this is Flex Builder... I don't have any /site-builder/ directory under layout, so not sure), and seems to require that I define a new region INSIDE an existing or new "row" -- which I guess causes it to be rendered in page html. I would like to define the region, but not render it.

This AT/Flex-Builder will pass along "region_hidden" as a key to theme.info.html, but then the region is hidden from Blocks UI, where i need to use it.

Please jump down to #9 & #10 below -- my other comments are now irrelevant.

mudd’s picture

Issue summary: View changes
mudd’s picture

Issue summary: View changes
mudd’s picture

Title: theme.info.yml is overwritten when settings saved -- customizations lost » theme.info.yml is overwritten when settings saved - How do I add a region?
Issue summary: View changes
mudd’s picture

Issue summary: View changes
mudd’s picture

Ok, so I found the file my_theme/layout/page-layout/page-layout.markup.yml, and added:

  hidden:
    attributes:
      id: hidden
    regions:
      hidden:
        label: 'Hidden'
        order: 1

Now, I go into appearance settings, and Save layout settings, and then region "hidden" magically appears in my_theme.info.yml file, and shows up in structure/block. Yay!

So I can now go ahead and use it?

mudd’s picture

Issue summary: View changes
mudd’s picture

Is AT treating the file, theme/layout/page-layout/page-layout.markup.yml, BOTH to define regions AND a template? Please let me know if there's a way to prevent render BUT not hide it from the Blocks UI (I mention 'regions_hidden' below)

mudd’s picture

Category: Support request » Bug report

I found this page -- https://www.lowfidelity.at/blog/adding-block-regions-drupal-8-using-adap...

This describes the exact situation: "Following the default approach of adding the region in the YOURTHEME.info.yml and page.html.twig, you'll quickly realize, that your changes are overwritten, when fiddling with your theme's settings..."

But my sub-theme doesn't have a /site-builder/ directory under layout. There's also no trace of "site-builder" anywhere under my sub-theme or in at_core. What now?

Changing this to a bug since there is historical reference to what seems should be a simple/supported task.

mudd’s picture

I think this issue perhaps lies both with TB Mega Menu and with AdaptiveTheme. I don't believe either is "at fault", rather they are simply a bit incompatible. (from what I know so far)

TB Mega Menu, in order to place blocks on their menu, the blocks must first be "placed" into any region. They claim this is necessary [something like the blocks need to be present in a particular table(??)]. Thus, a "hidden" region is prescribed. The old pre-Symfony way is to define a region in theme.info (now in .yml) and then leave it out of the page template (old .php, new .twig). This still works when using twig templates.

AdaptiveTheme however uses twig system [Flex Builder?] which isn't the simple model of having a full set of twig template files for all pages, form, views, etc. I don't fully understand the AT/Flex_Builder model so I'm not able to figure out how to pass some sort of instruction to omit a particular row or region from it's html output. AT/FB uses a "row" key in page-layout.markup.yml, and I can only figure out how to create a custom region when defining it inside a row.

It seems the Symfony way to hide a region is "regions_hidden", ala (confusing because my custom region ID is named "hidden"):

regions_hidden:
  - hidden

AT seems to properly pass this along to theme.info.yml. But it WONT pass along a simple region def:

regions:
  hidden: 'Hidden'

So although I can define a region inside a row, and then hide it:

rows:
  hidden:
    attributes:
      id: hidden
    regions:
      hidden:
        label: 'Hidden'
        order: 1
regions_hidden:
  - hidden

...this correctly prevents the region from being rendered in page html, but it also hides the region from the Blocks UI, thus tripping up TB Mega Menu. So I wish TBMM didn't require blocks to be pre-placed and all this hidden region business.

I noticed that AT has a "hide" checkbox in the layout rows suggestions, but all this does is add a CSS rule to display:none. So I'm just doing this to the entire row in my theme css, which is easier than using all those checkboxes:

div.l-hidden {
	display: none;
}

This work around will do for now, but I'd really like to find a way to create a region and hide it by telling the template engine to not render it, without using regions_hidden.

mudd’s picture

Title: theme.info.yml is overwritten when settings saved - How do I add a region? » How do I add a custom region without rendering it?
Category: Bug report » Support request
Issue summary: View changes

Should I switch 4.1 to 5.x or Dev? (this module installs as /themes/contrib/adaptivethemes/, right?)

mudd’s picture

Issue summary: View changes

I finally found that I could prevent rendering of the region using theme_preprocess_html in mytheme.theme (however theme_preprocess_page was the method most of the recipes I found indicated. This post suggested using theme_preprcess_html):

function mytheme_preprocess_html(&$variables) {
  if (TRUE) {
    unset($variables['page']['hidden']);
  }
}