Let the visitor filter search $results

I want to add filtering options to my search component in the template, for example: show only book pages or show only magazine pages.

I guess that I need to affect this $results var somehow and I wonder what is the best practice for that.

This is my search controller:


return function ($site) {

    $query   = get('q');
    $results = $site->index()->listed()->bettersearch($query);

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


Is this an Ajax case?
Thanks in advance!

There are several options:

  1. Do it only on frontend with JavaScript
  2. Via an link and a parameter that you can filter by in your controller (see categories here: Cookbook | Kirby CMS)
1 Like