backdrop-contrib / mini_layouts

Provide blocks which allow positioning content within them in layouts.
GNU General Public License v2.0
7 stars 4 forks source link

Some blocks should probably be prevented from being chosen inside a mini layout #3

Closed herbdool closed 2 years ago

herbdool commented 2 years ago

Should a mini layout block be able to embed itself? I see it available in the list. Should "Page title" be suppressed? What about "Main content page"? Maybe that's ok.

herbdool commented 2 years ago

Yup, Page title should be suppressed (the one that shows up by default when choosing a template). Is this a matter of telling the layout what the context is?

Screenshot from 2021-10-26 14-51-08

docwilmot commented 2 years ago

I did notice this and thought of how page title and tabs could be suppressed, and failed. Problem is that

  1. those regions are hard-coded in the templates <?php if ($tabs): ?><nav></nav><?php endif; ?>
  2. layout_preprocess_layout() runs after any attempted override (its meant to run last and is given a weight to ensure this) and does $variables['tabs'] = menu_local_tabs()

So failing any bright ideas, I suspect we'll need to avoid templates with tabs and titles.

philsward commented 2 years ago

I'll agree that a mini-layout shouldn't be able to embed itself... I noticed this too when testing and thought it was an odd behavior. I can't see any reason why a mini-layout would ever need to add itself and to infinity no-less.

docwilmot commented 2 years ago

And the block add list isnt alterable.

herbdool commented 2 years ago

Maybe this is a need for a new hook in core.

herbdool commented 2 years ago

Maybe this module could add a handful of simple layouts to steer someone away from other ones. Is there a way to categorize the layouts?

philsward commented 2 years ago

Could a simple css "display: none" be added for a quick and very dirty workaround?

docwilmot commented 2 years ago

Found a one-liner trick to hide page components. Still cant prevent adding a block to itself yet. But the code wont let that render anyway.

philsward commented 2 years ago

This doesn't really help with the conversation, its more of an FYI. I added a mini-layout to a mini-layout and it effectively broke the site... I could visit the home page but it wouldn't load any other pages. So, not only should it not be allowed to add itself, it's quite broken if it does.

docwilmot commented 2 years ago

I added a mini-layout to a mini-layout and it effectively broke the site

Fixed that. Can still add block within block but will not render if you do.