Skip to content

Kirby 3.6.6

$page->search()

Search all pages within the current page

$page->search(string $query = null, array $params = [ ]): Kirby\Cms\Pages

Parameters

Name Type Default
$query string null
$params array [ ]

Return type

Kirby\Cms\Pages

Parent class

Kirby\Cms\Page

Example

// search the entire site
$results = $site->search('my awesome search');

// search all children, children of children, etc. of the current page
$results = $page->search('my awesome search');

// filter the search results
$results = $page->search('my awesome search')->listed()->filterBy('template', 'article');

// add pagination to the search results
$results = $page->search('my awesome search')->paginate(20);

// search in certain fields only
$results = $page->search('my awesome search', 'title|text');

// search for full words only
$results = $page->search('my awesome->search', ['words' => true]);

// feed the search with a get parameter -> http://yourdomain.com/?q=awesome
$results = $page->search(get('q'));