Search results for Builder Blocks and more …

How do I get search results for Kirby Builder fields?
I would also like to search in other fields like user name and bio and image captions for example. The snippet below returns results for title, description, tags. The text field for example is a Builder field (used in several blocks).

<?php

return function ($site) {

  $query   = get('q');
  $results = $site->index()->children()->listed()->search($query, 'title|description|text|columntext|author|bio|tags|caption');

  return [
    'query'   => $query,
    'results' => $results,
  ];

};

Adjusting the results:

$results = $site->index()->children()->listed()->search($query);

Gives me more result, the search function seems to biased though, Tim is in favour Marco only gets 1 result

Kirby only searches in fields, not in subfields, so you would have to add the builder field to your search options.

Well I do get results now with search($query) from a Builder field

Without adding the builder field itself to the list of fields?

Yes, just search($query)

Ok, if you don’t explicitly list any field, then it searches in all fields.

1 Like

Yes, it’s fine for now.