I can think of many scenarios that it will simplify the process of visibility settings if a block was allowed in more than 1 visibility groups

this way visibility groups would exist with smaller condition sets

here is a real scenario

already have seperate visibility groups
category 1
category 2
category 3
category 4
category 5
category 6
...

because of this particular use case I need them seperate
but there is a case where one particular block is to be visible for ANY of the above categories

one has to create a seperate visibility group for all the above

it would make sense (to me at least) if I was able to choose all the above category which would be consider as OR conditions

hope it makes sense

CommentFileSizeAuthor
#49 block_visibility_groups-n2864027-49.patch28.58 KBDamienMcKenna
#49 block_visibility_groups-n2864027-49.interdiff.txt874 bytesDamienMcKenna
#47 block_visibility_groups-n2864027-47.patch28.51 KBDamienMcKenna
#47 block_visibility_groups-n2864027-47.interdiff.txt1.69 KBDamienMcKenna
#45 block_visibility_groups-n2864027-45.interdiff.txt1.44 KBDamienMcKenna
#45 block_visibility_groups-n2864027-45.patch27.7 KBDamienMcKenna
#43 block_visibility_groups-n2864027-43.patch27.08 KBDamienMcKenna
#43 block_visibility_groups-n2864027-43.interdiff.txt841 bytesDamienMcKenna
#41 block_visibility_groups-n2864027-41.patch27.08 KBDamienMcKenna
#41 block_visibility_groups-n2864027-41.interdiff.txt2.31 KBDamienMcKenna
#39 block_visibility_groups-n2864027-39.patch25.33 KBDamienMcKenna
#39 block_visibility_groups-n2864027-39.interdiff.txt1.16 KBDamienMcKenna
#37 block_visibility_groups-n2864027-37.patch25.14 KBDamienMcKenna
#37 block_visibility_groups-n2864027-37.interdiff.txt1.54 KBDamienMcKenna
#35 block_visibility_groups-n2864027-35.patch24.78 KBDamienMcKenna
#35 block_visibility_groups-n2864027-35.interdiff.txt6.08 KBDamienMcKenna
#33 block_visibility_groups-n2864027-33.patch19.36 KBDamienMcKenna
#33 block_visibility_groups-n2864027-33.interdiff.txt926 bytesDamienMcKenna
#31 block_visibility_groups-n2864027-31.interdiff.txt927 bytesDamienMcKenna
#31 block_visibility_groups-n2864027-31.patch19.36 KBDamienMcKenna
#29 block_visibility_groups-n2864027-29.patch19.34 KBDamienMcKenna
#29 block_visibility_groups-n2864027-29.interdiff.txt877 bytesDamienMcKenna
#27 block_visibility_groups-n2864027-27.patch19.01 KBDamienMcKenna
#27 block_visibility_groups-n2864027-27.interdiff.txt1.02 KBDamienMcKenna
#25 block_visibility_groups-n2864027-25.patch19.01 KBDamienMcKenna
#23 block_visibility_groups-n2864027-23.patch19.01 KBDamienMcKenna
#18 block_visibility_groups-n2864027-18.patch19.06 KBDamienMcKenna
#14 interdiff_12-14.txt616 bytesrp7
#14 block_visibility_groups-multiple_groups_per_block-2864027-14.patch18.85 KBrp7
#12 interdiff_11-12.txt4.8 KBbaikho
#12 block_visibility_groups-multiple_groups_per_block-2864027-12.patch18.84 KBbaikho
#11 interdiff_9-11.txt1.06 KBbaikho
#11 block_visibility_groups-multiple_groups_per_block-2864027-11.patch13.76 KBbaikho
#9 interdiff_4-9.txt19.48 KBbaikho
#9 block_visibility_groups-multiple_groups_per_block-2864027-9.patch12.59 KBbaikho
#4 block_visbility_groups_multiple_groups_single_block.JPG59.33 KBrp7
#4 block_visibility_groups-multiple_groups_per_block-2864027-4.patch7.79 KBrp7
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GiorgosK created an issue. See original summary.

GiorgosK’s picture

Perhaps a more advanced interface could incorporate conditions (visibility groups) and from the individual block settings one could include or exclude conditions and thus with a small set of visibility groups one could have countless more visibility options

rp7’s picture

Working on a project that needs exactly this. We have several visibility groups and have certain blocks that should be displayed if one of those groups are matched. AFAICT, currently the only way to achieve this is to add the same block multiple times & assign each a different visibility group... which is pretty cumbersome.

rp7’s picture

Patch attached is the first attempt at this. This is how the form looks like:

Multiple visibility groups, single block

You can select multiple visibility groups and choose whether each one needs to match (AND operator) or only 1 (OR operator).

I've currently implemented this as a completely separate condition ("condition_groups"), which is why you are seeing a "Condition group" and a "Condition groups" tab. The reason for this is to not break backward compatibility with existing installations.

I guess we can provide an update hook that does the conversion, but perhaps we should first decide whether we want this functionality in the module & if this way (screenshot) is the way to go forward.

baikho’s picture

Status: Active » Needs review

Thanks @rp7 for your work on this!

The other day I was in need of this feature and I definitely think this adds value to the module. Marking this as "Needs review" and will test the patch when I get to it.

Niklan’s picture

Status: Needs review » Reviewed & tested by the community

Tested patch #4, works as expected. Thank you, it is much simpler now to handle block visibility.

Change to RTBC to push this issue forward.

mlncn’s picture

Status: Reviewed & tested by the community » Needs review

This is great.

I think we probably want to either try to get a good user experience under one tab, or to put this in an optional submodule for now.

Would appreciate further review (including of the wording / UX) and thoughts on one tab or two.

rp7’s picture

If this is desired functionality, I think we should definitely have 1 tab & provide an update hook that does the conversion for existing installations. Unfortunately, I currently don't have the time to work on this.

baikho’s picture

Agreed, I don't think it makes sense to have 2 tabs. I have gone ahead and added an update hook to convert the existing condition group references and the operator string to the new variant as per comment #8.

Tests are likely to fail.

Status: Needs review » Needs work

The last submitted patch, 9: block_visibility_groups-multiple_groups_per_block-2864027-9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

baikho’s picture

baikho’s picture

Assigned: Unassigned » baikho
rp7’s picture

alextenczar’s picture

@rp7 Any update on this patch? (#14)

mlncn’s picture

This needs a re-roll now. Curious also about thoughts with regards to more generalized complex rule modules, #3302768: Plan potential future integration with context stack, ECA, and/or Rules.

DamienMcKenna’s picture

Assigned: baikho » DamienMcKenna
Status: Needs work » Needs review

Working on a reroll.

DamienMcKenna’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Assigned: DamienMcKenna » Unassigned
FileSize
19.06 KB

Rerolled. Hopefully.

DamienMcKenna’s picture

While there is an update script for fixing the configuration, would it be worth including logic in buildConfigurationForm(), calculateDependencies(), getCacheTags(), getCacheContexts() and getCacheMaxAge() to support a single value?

DamienMcKenna’s picture

Assigned: Unassigned » DamienMcKenna

(waiting for the v2 tests to be enabled, then I'll finish off any issues that arise on this issue)

DamienMcKenna’s picture

This should go into a 2.1.x release, as it's a new feature.

DamienMcKenna’s picture

DamienMcKenna’s picture

Status: Needs review » Needs work

The last submitted patch, 23: block_visibility_groups-n2864027-23.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
19.01 KB

Rerolled.

Status: Needs review » Needs work

The last submitted patch, 25: block_visibility_groups-n2864027-25.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

Trying to fix those tests.

Status: Needs review » Needs work

The last submitted patch, 27: block_visibility_groups-n2864027-27.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

Trying to debug this from the runtime output as it's failing locally because of something else.

Will this fix it?

Status: Needs review » Needs work

The last submitted patch, 29: block_visibility_groups-n2864027-29.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

DamienMcKenna’s picture

Status: Needs work » Needs review
DamienMcKenna’s picture

Status: Needs review » Needs work

The last submitted patch, 33: block_visibility_groups-n2864027-33.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

The config value was only partially renamed from 'block_visibility_group' to 'block_visibility_groups', a few uses of the older argument existed so let's see if this is better.

Status: Needs review » Needs work

The last submitted patch, 35: block_visibility_groups-n2864027-35.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

This fixes the problem locally.

Status: Needs review » Needs work

The last submitted patch, 37: block_visibility_groups-n2864027-37.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

This should fix it.

Status: Needs review » Needs work

The last submitted patch, 39: block_visibility_groups-n2864027-39.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

Let's see if this fixes the problem.

Status: Needs review » Needs work

The last submitted patch, 41: block_visibility_groups-n2864027-41.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

Status: Needs review » Needs work

The last submitted patch, 43: block_visibility_groups-n2864027-43.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

Status: Needs review » Needs work

The last submitted patch, 45: block_visibility_groups-n2864027-45.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

Status: Needs review » Needs work

The last submitted patch, 47: block_visibility_groups-n2864027-47.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

Status: Needs review » Needs work

The last submitted patch, 49: block_visibility_groups-n2864027-49.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.