Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
ContextAwarePluginAssignmentTrait allows configuring the context mapping where there are multiple matching contexts, but it does not support to not pass a value to a non-required context.
I encountered this with Page Manager, where a matching context needs to be prevented from being passed on to a views block contextual filter.
Proposed resolution
Add a "- None -" option if the context is not required.
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#17 | context-optional-2484645-17.patch | 4.03 KB | giancarlosotelo |
#17 | interdiff-11-17.txt | 1.47 KB | giancarlosotelo |
#11 | context-optional-2484645-11.patch | 3.53 KB | giancarlosotelo |
#11 | context-optional-ONLYTEST.patch | 1.69 KB | giancarlosotelo |
#3 | context-optional-2484645-3.interdiff.txt | 622 bytes | Arla |
Comments
Comment #1
ArlaComment #2
ArlaIn Core, this trait is only used by ConditionFormBase. None of the condition plugins have optional contexts, so, for testing, I guess we need another test condition plugin.
Comment #3
ArlaThe empty mappings should not be stored, because then ContextHandler::applyContextMapping() breaks.
Comment #8
Bojhan CreditAttribution: Bojhan commentedCan we start up the design process? including all the UI work?
Comment #11
giancarlosotelo CreditAttribution: giancarlosotelo at MD Systems GmbH commentedRebased and I found a plugin test in Blocks with context mapping, so I am using it and also adding the test to a function that is testing context mapping but I don't know if is the best way.
Comment #16
ArlaNice. Would be great if we can also test the block in action. I don't really understand the existing test - the block does not appear because it accepts context? Can we not place the block in some region, select "None" for the context mapping, and check that the block shows up? (As said, I'm not really sure how this stuff works...)
Comment #17
giancarlosotelo CreditAttribution: giancarlosotelo at MD Systems GmbH commentedOk, I am editing the block and set the context to none to check the result of the block.
Comment #18
BerdirTest looks OK to me.
In #2377757: Expose Block Context mapping in the UI, toward the end, we discussed making those elements always visible (or I suggested it). That seems useful to me, otherwise it is very hard to understand what context the block is using and there are contexts.
But I'm not sure about doing that here, we might not be able to do that without a UX discussion, especially now in RC code freeze.
So I think it is fine to keep it as it is. It will not show up anywhere in core right now, but it will be useful for example with #2287073: Allow views contextual filters to expose the context using argument validation plugins.
Comment #19
tim.plunkettStraight forward fix that would be hard to fix in contrib.
Comment #20
xjmThe Drupal 8 committers discussed this and agreed that it should be an RC target.
Comment #21
catchCommitted/pushed to 8.0.x, thanks!
Comment #23
borisson_In #18 @berdir suggested always showing the form element. @StryKaizer opened a new issue for that in #2603454: Show context in blocks when only one context is available.