4

The issue at hand is to change the display of one of a View's fields, based on a condition in another field of the same View. The field to be affected is the display of checkboxes associated with Flag Lists/List Operations. The conditional field would have a value "yes" or "no" and would be excluded from display. Ideally, the checkbox would simply be absent if the value is "no." Alternatively or additionally, it would be helpful to display a message explaining why the item can't be selected to include in a list. Can anyone provide suggestions for a general approach? Thank you for any help and suggestions.

5

By conditional field do you mean a simple Boolean? If so, you should be able to pull this off with some tactical field rewriting.

When creating the Boolean in your content or entity type, have 'Yes' as the only value, leaving the unchecked state assumed as no. Then in views add the flag list field first and exclude. Next the Boolean but don't exclude. Use its default formatting not its key. In its settings rewrite using the flag list field replacement pattern, and in the empty behaviour (eg the result of the empty checkbox when no value has been specified for it), choose to hide rewriting.

You may need to fine tune this or perhaps add additional fields, chasing the replacements until it works. You'll be amazed at the sophisticated conditions you can set up in this fashion.

  • THANK YOU, Peter, for this insightful suggestion. I applied it, and it works! Now I need to find a way to put into that Views table cell a message explaining why checkbox-selection is not available. (otherwise user may just think it's a malfunction) Ultimately the goal is to prevent certain items from being put into a list that's shared via URL, and this whole approach may not be the best way. But your suggestion works for this approach, and the general method described has taught me a new way to think about rewrites. – Charles Apr 25 '13 at 16:15
  • I'm glad that worked! You should be able to add the message in the Boolean field's No Results Text (in Empty Behaviour). – Peter Clemence Apr 25 '13 at 17:07
4

maybe Views Conditional could be useful for small conditionals:

Views Conditional is a simple module that allows you to define conditionals (if xxx then yyy). with fields in views. Conditions include:

  • Equal To
  • Not Equal To
  • Greater Than
  • Less Than
  • Empty
  • Not Empty

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.