Possible to search multiple pages at once?

I’m trying to make a search option which let’s you filter the search results by certain (user selected) pages that but I can’t seem to be able to make a collection which would work for the search() function? The pages could be a mix of top level pages and subpages so for example: content/01-news/ and content/02-support/01-docs/

Is this possible somehow?

you can filter your collection prior your search first, there’s many different operators to use…


$site->index()->filterBy('template','==', 'some-template')->search(...)
$site->index()->filterBy('field','==', 'some-value')->search(...)

If filtering is not sufficient, you can merge collections or add pages to a selection prior to using the search method.

Should the search method work if I’ve created my own collection like this?

$pagescollection = new Collection();

and then appended data into it?

You need an object of type Pages; so you can do:

$pagescollection = new Pages();

and then append to it.