O'Reilly logo

Mastering Drupal 8 Views by Gregg Marshall

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

If-then-else conditional rewrites

Jim continued, "There are times when you'd like to display one of two different fields depending on some condition. Almost always, when we hear that a client wants to do something like this, we start planning on custom code to implement it. Many of these would be really hard to implement in Views, but some are of the form that if I have information in field X, then display it and otherwise display field Y. These kinds of requests can be handled within Views using the REWRITE RESULTS and NO RESULTS BEHAVIOR fieldsets."

No results options

"We haven't really covered the NO RESULTS BEHAVIOR fieldset, which looks similar to this when expanded:

No Results Behavior options

This is pretty straightforward. If a field is empty, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required