There are fields in my view that I would rather hide depending on the value of another field. I am lookinf for ways to do it in code, or otherwise but without enabling php filter.
I don't know which version of Views you use. I can't quite remember whether output rewriting was available in V2, but I suppose it was. In V3, it's there, waiting for you to use it.
Output rewriting accepts any HTML code and you can use replacements from what the query returned. I'm not sure you can use PHP there, perhaps you can, but I've never really tried. Anyways, let's say you have field_foo and field_bar, and that both are some select options or checkboxes or some other multiple choice thing, having key-value pairs in the database (like 1|foo, 2|bar etc.).
In this situation, you should have four options available:
[field_foo_value]
[field_foo_value_raw]
[field_bar_value]
[field_bar_value_raw]
(they'll probably be named a bit differently, I can't quite remember the exact naming convention). You can rewrite the "bar" field output like this:
<span class="visibility-[field_foo_value_raw]">[field_bar_value]</span>
Then, assuming the possible keys for "foo" are 1 and 2, you can write some CSS:
span.visibility-1 { display: inline; }
span.visibility-2 { display: none; }
If PHP is allowed, it should be even easier, but I have a feeling you can only use HTML. Anyway, I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With