1

Which one of the following is the correct of way of checking if an element field like images, entries or category is not empty?

  1. {% if entry.fieldHandle.one() %}
  2. {% if entry.fieldHandle.all() %}
  3. {% if entry.fieldHandle.count() %}
  4. {% if entry.fieldHandle | length %}
  5. {% if entry.fieldHandle.exists() %}
  6. {% if entry.fieldHandle %}
2

They'll all work except for the last one:

entry.fieldHandle.one()
entry.fieldHandle.all()
entry.fieldHandle.count()
entry.fieldHandle | length
entry.fieldHandle.exists()
| improve this answer | |

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.