Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello, I have made a patch to allow multiple values to compare fields against.
Use case: I needed to be able to do:
if content type == type1 or type2 then show image at this style else show alternate style.
I could not do that with current version so I made this patch, hope it's useful to someone.
Comment | File | Size | Author |
---|---|---|---|
#14 | 2690167-14.patch | 5.42 KB | Megha_kundar |
#6 | allow-multiple-values-2690167-6.patch | 4.97 KB | dave.erwin |
#5 | allow-multiple-values-to-compare-field-against-2690167-5.patch | 4.97 KB | dave.erwin |
Comments
Comment #2
dave.erwin CreditAttribution: dave.erwin commentedComment #3
dave.erwin CreditAttribution: dave.erwin commentedComment #4
dave.erwin CreditAttribution: dave.erwin commentedComment #5
dave.erwin CreditAttribution: dave.erwin commentedresubmitting patch for review
Comment #6
dave.erwin CreditAttribution: dave.erwin commentedrerolling patch to see if it gets auto tested
Comment #7
dave.erwin CreditAttribution: dave.erwin commentedComment #8
dave.erwin CreditAttribution: dave.erwin commentedComment #9
mvcThis works fine when the delimiter is present but if it's blank you get the PHP warning "explode(): Empty delimiter". There should be a checkbox for using an array delimiter at all to account for that case. The default should probably be to not use a delimiter.
Otherwise, very nice!
Comment #10
kellyimagined CreditAttribution: kellyimagined commentedA temp fix:
Comment #11
hkdorama CreditAttribution: hkdorama commentedIt would make sense to have multiple conditions that check against values of multiple fields. Like this:
If
(fieldOne.value = x (and/or y) then display z in thisField)
and/or
(fieldTwo.value = a (and/or b) then display C in thisField)
Comment #12
tonytheferg CreditAttribution: tonytheferg commentedI second that @mvc #6. Great function. Just need to enable with a checkbox.
Comment #13
Megha_kundar CreditAttribution: Megha_kundar commentedComment #14
Megha_kundar CreditAttribution: Megha_kundar commentedComment #15
tonytheferg CreditAttribution: tonytheferg commented#14 works! I think the delimiter field should be required if the checkbox is enabled. This would make it even more "fool proof".
If you delete the delimiter with the checkbox on, you get the following two warnings for every instance of that field:
Warning: Invalid argument supplied for foreach() in ViewsConditionalHandler->render() (line 341 of *\sites\all\modules\views_conditional\includes\views\handlers\views_conditional_handler.inc).
Warning: explode(): Empty delimiter in ViewsConditionalHandler->render() (line 271 of *\sites\all\modules\views_conditional\includes\views\handlers\views_conditional_handler.inc).
Comment #16
chucksimply CreditAttribution: chucksimply commentedAny solutions for Drupal 8?
Comment #17
cebab54 CreditAttribution: cebab54 as a volunteer commentedresolved in Drupal 8 and 9 with use of twig conditionals