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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dave.erwin created an issue. See original summary.

dave.erwin’s picture

dave.erwin’s picture

Status: Active » Needs review
dave.erwin’s picture

dave.erwin’s picture

resubmitting patch for review

dave.erwin’s picture

rerolling patch to see if it gets auto tested

dave.erwin’s picture

Status: Needs review » Active
dave.erwin’s picture

Status: Active » Needs review
mvc’s picture

Status: Needs review » Needs work

This 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!

kellyimagined’s picture

A temp fix:

  • Add fields to look at as exclude from display
  • Create a global content text field in view
    • Add replacement patterns for the excluded fields as the content
    • Add conditional view looking strlen greater than 2
hkdorama’s picture

It 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)

tonytheferg’s picture

I second that @mvc #6. Great function. Just need to enable with a checkbox.

Megha_kundar’s picture

Assigned: Unassigned » Megha_kundar
Megha_kundar’s picture

Assigned: Megha_kundar » Unassigned
Status: Needs work » Needs review
FileSize
5.42 KB
tonytheferg’s picture

#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).

chucksimply’s picture

Any solutions for Drupal 8?

cebab54’s picture

resolved in Drupal 8 and 9 with use of twig conditionals