Reference

$site->search()

Search all pages in the site

$site->search(string $query = null, array $params = [ ]): Pages

Parameters

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

Return type

Pages

Possible parameters/defaults

$defaults = [
  'minlength' => 2,
  'fields'    => []
  'words'     => false,
  'score'     => []
];

Example

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

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

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

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

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

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

Source code

kirby/src/Cms/Site.php#L498