How to execute a Kirby query from within PHP?

I want to have a text field where the editor can write a Kirby query. Then, in the template, I want that query to be evaluated as if it was used in a blueprint setting like query for pages.

You can do that via the Query class: https://getkirby.com/docs/reference/tools/query/__construct

Example: https://github.com/texnixe/k3-filesdisplay-section/blob/dc8417b31bc6006e5264f5718feb404109c18b3b/src/FilesDisplaySection.php#L23

1 Like