Reputation: 23593
With Drupal Views, how can I hide a Field if another Field is not empty? In other words, how can I show a Field unless its empty, then show a different Field?
I have the following;
Node1 fieldA - text for field A in Node 1 fieldB - text for field B in Node 1
Node2 fieldA - (empty) fieldB - text for field B in Node 2
I want to show fieldA, unless it's empty in which case i wanted to show fieldB. So my View would show;
'text for field A in Node 1' 'text for field B in Node 2'
How can I do this? I can hide a filed if its empty, but how can I hide a field if another field is not being hidden?
In case it matters, the reason im doing this is im using image cache to generate thumbnails for a gallery. However for some thumbnails I want to be able to upload a different image to be used as a thumbnail. Thanks
Upvotes: 3
Views: 4811
Reputation: 1810
It would appear this can now be achieved using the 'rewrite if empty' behavior, which allows replacement tokens from the view - the trick is that you need to put 'field b' first in the order of the view fields, and hide it from displaying. Then in the 'field a' settings, set the no results behavior to the token for 'field b' (usually something like [field_b]) ...logically this means if field A has a value it will be displayed, but if not (no results) field b will be displayed instead.
Upvotes: 2
Reputation: 11
http://drupal.org/sandbox/benclark/1213836
A new sandbox module is available that provides this functionality.
Upvotes: 1