Extend panel search

Hi all,

I am currently testing this code snippet to extend the default panel search.

Kirby::plugin('example/search', [
  'areas' => [
    // extending a core search
    'site' => function ($kirby) {
      return [
        'searches' => [
          'pages' => [
            'query' => function (string $query) use ($kirby) {

              if (!$kirby->user()->isAdmin()) {
                // return only child pages of a page (via specified UUID)
              }

              return $kirby->core()->area('site')['searches']['pages']['query']($query);
            }
          ]
        ]
      ];
    },
  ]
]);

However, “no result” appears in the search panel. How do you return the unchanged search results?

Background: I would like to customize the panel search so that the search is limited to different pages and their subpages for the user roles editor and reviewer.

Roland

Thank you, seems you spotted a mistake in the docs. It should be

'query' => function (string|null $query, int $limit, int $page) use ($kirby) {
	// ...

	return $kirby->core()->area('site')['searches']['pages']['query']($query, $limit, $page);
}

For your custom results, best to check kirby/config/areas/site/searches.php at main · getkirby/kirby · GitHub to see what you need to return.

So it works perfectly, thanks for the answer and the link!