This module enables a view to output a field if another field is empty.

You need Views If Empty when

You have a content type with an embedded video and an imagefield thumbnail. The nodes always have the images but occasionally have a video. You want your view to display the image field when the video field is empty, display the video field when available, and never display both.

Installation & Usage

Install normally. Add or edit a view where the row style utilizes fields, and add a Views If Empty field.

In the options form for the Views If Empty field, select the 'If this field is empty' field. This is the field that is checked whether it is empty or not. (In the above example, this would be the video field.)

Next, select the 'Then output this field' field. This is the field that is output when the empty field is empty. (In the above example, this would be the image field.)

Frequently Asked Questions

Why am I not seeing the field I want to use in the list of available fields?

The order of the fields in the view will affect the Views If Empty field. It will only allow selections from fields that come before the Views If Empty field. To fix this, reorder the Views If Empty field so it comes after the field(s) you want to use.

Why am I seeing duplicate content in my views row?

In most use cases, you will need to mark both the empty field and the output field to be "excluded" via their option forms. That way, only the Views If Empty field is outputting content from either of those fields.

What if I want to have more than one "if empty" field? If field A and field B are both empty, can I set this to display field C?

You can daisy-chain multiple Views If Empty fields together (see #1842602-3: Document multiple "If this field is empty" fields.) So, given fields A, B and C in the example, you would create the following Views If Empty fields:

  1. Views If Empty 1: field A is empty field, and Views If Empty 2 is output field.
  2. Views If Empty 2: field B is empty field, and field C is output field.

Project Information