Query language query :)

I’m trying to filter images in files field so that it lists images from the sites subpages but only if the “splash” toggle is set to true in the files meta.

According to the docs, something like this should work but it doesn’t, it’s listing all images, and ignoring the filterby…

query: site.children.listed.images.filterBy("splash", true)

Basically the site has a splash page and the background is set from select images stored on all of the sites subpages.

What does the field actually store? An integer or true/false?

true / false…

----

Splash: true

----

Should work with quotation marks then:

query: site.children.listed.images.filterBy("splash", "true")

I don’t know why this is stupid, think we had the same issue in K2.

Nope… doesn’t do it either. The fields default is false. I have about 20 images on a subpage, three of which are set to true, but i’m getting the whole lot in the pop up to pick from.

It’s Kirby 3.1.3

Hm, this seems to work, but seems crazy or a bug:

query: site.children.listed.images.filterBy("splash", 'true')

with true in single quotes…

Do you mean it doesnt always work, or having wrap it in qoute is crazy? :crazy_face:

Having to wrap it in quotes and especially single quotes, with double quotes NOT working.

Yes, that’s confirmed for me too - it works in my project with single quotes. Shall i log it on github, or will you? :slight_smile:

Could you, please?

Sure :slight_smile: … after some :zzz: :sleeping_bed:

:zzz: :sleeping_bed: Complete.

So is the GitHub Issue…

I just noticed it also doesn’t work in templates unless you single quote, so the issue is not just limited to the query language…

$site->children()->listed()->images()->filterby("featured", 'true')

I’ll try to test with the new feature branch later if the issue persists.

1 Like