Page field - Query for non-empty values

Hello. Is it possible to setup a pages field that queries for pages that have a specific field filled out/not empty. If it helps understand… I want the user to select a testimony from one of the website’s case study pages. I only want to present the user with case study pages that actually have a testimony. Any insight?

Yes, that’s possible. This should work:

query: site.find('case-studies').children.listed.filterBy('fieldname', '!=', '')

As an alternative, you could check if the field value has a min length:

query: site.find('case-studies').children.listed.filterBy('fieldname', 'minlength', 100)

Change page slug and field name as required.

1 Like

Excellent. Just for those interested you gotta make sure your use the dot syntax for the fields like this…

query: site.find('case-studies').children().listed().filterBy('fieldname', '!=', '')

Thanks @texnixe

Oops, sorry, of course