- Issue created by @darkodev
- πΊπΈUnited States kevinquillen
A Context is nothing more than a collection of conditions. it can be executed and applied to more than just blocks. They are also reusable. For example, imagine having to set 5 conditions on 10 blocks across a few nodes. This would take longer and be error prone if you don't get all the settings correct. With a Context, you just select it.
I recently started using Layout Builder for the first time and wanted to get a feature from Acquia Site Studio. They allow applying Contexts to containers, components and elements. Containers are analogous to Layouts, components are analogous to block components. There is no 'elements' equivalent in Layout Builder.
Here is an edit tray on a container in Site Studio for example:
Layout Builder Context provides the same effect.
The one thing I would like to do is get the ability to add multiple Contexts to a layout or block, then it would meet parity IMO.
- π¨π¦Canada darkodev
Thanks for the great comments, Kevin!
One of the features that we're looking for in the other thread is to allow visibility based on a field's value, for example (we have been doing this in Panels visibility rules in D7 rather than Context).
Unfortunately, it doesn't work in Layout Builder modal because of an AJAX callback route issue.
https://www.drupal.org/project/drupal/issues/2916876#comment-14286454 β¨ Add visibility control conditions to blocks within Layout Builder Needs work
https://www.drupal.org/project/entity_field_condition/issues/3248365 β¨ Core Layout Builder Compatibility - AJAX Error ActiveI suppose this could be tackled in a Context with the help of your module.
Time to dive back into Context module after many years away ...
- πΊπΈUnited States kevinquillen
Yes, that is because the form structure for block visibility and context is different.
My general advice was to try and avoid using AJAX in those forms at all. I posted a workaround here:
https://www.drupal.org/project/entity_field_condition/issues/3278442#com... π fields of bundle are not loaded when using Context UI Needs review
- πΊπΈUnited States kevinquillen
These two additions were put in quickly today:
- β¨ Allow multiple contexts to be applied to a layout or block component Fixed
- β¨ Allow editor to select 'all' or 'only one' pass condition for a set of Contexts Fixed
After this point it is likely just code cleanup and testing.
- πΊπΈUnited States kevinquillen
I think it seems close at this point, but there are two issues I think need to be resolved:
- π Add tests Fixed
- π Adding new content and overriding the layout does not inherit the Context settings on the original layout from Layout Builder Closed: cannot reproduce
The second one seems like Layout Builder behavior I am not quite familiar with.
- πΊπΈUnited States kevinquillen
Just tagged a beta release with decent test coverage.
- Status changed to Postponed: needs info
over 1 year ago 2:40am 27 May 2023 - πΊπΈUnited States kevinquillen
What other features could there be? Interested in ideas. My use case is more or less met. Although I am interested to see how it works in real Layout Builder driven projects.
- πΊπΈUnited States crutch
This is great. We are launching a 9.5.9 site tonight with layout builder, first time. Will need to try this module out next week. Yes #4 is what we need.
The issue we have right now, panels vs layout builder, is that when a view block is displayed on a page and there is no result, but there's actually a result in the view is some way, there is no way to hide the block with views or layout builder.
With Panels we could use visibility conditions to hide the block based on the value of a field of a node. But panels had a single item or entity where the condition could be set on the node variant. Layout builder could have a single item or entity where conditions could be set. When using "Allow each content item to have its layout customized." then it seems it wouldn't make sense for conditions to be used.
- πΊπΈUnited States amanire
This is a great little module. An important UI feature that I would like is a way to filter the list of contexts. Some of the contexts are created for other purposes and are irrelevant and inappropriate to use within layout builder. I'd like to minimize any confusion for our content admins. Layout builder is confusing enough as it is! It could be an option on a per context basis but I like the idea of associating it with one or more context groups.