Skip to content

Kirby 5.6.4

$field->query()

Uses the field value as Kirby query

$field->query(string|null $expect = null): mixed

Parameters

Name Type Default
$expect stringornull null

Return type

mixed

This method modifies the existing $field object it is applied to and returns it again.

The field value runs as a query with full access to Kirby's PHP API. Only use this method with fields that you would trust to contain PHP code. Never use it with content that comes from site visitors or with fields that Panel users with limited permissions can edit.

Learn more about trusted queries ›

Examples

Assuming your text field value is site.find('notes') this query will return the notes page. With the expect parameter, you can optionally define the expected return type, in this case a Kirby\Cms\Page object.

<?php
dump($page->text()->query('Kirby\Cms\Page'));