I'm trying to figure out how to apply multiple content type filters to the search results of the Search Block Form (not the normal search form). I've successfully filtered by current language and ONE content type. So far, here's what I have:
function mytheme_form_search_block_form_alter(&$form, &$form_state) {
$manager = \Drupal::languageManager();
$form['advanced-form'] = [
'#type' => 'hidden',
'#value' => 1,
];
$form['f[0]'] = [
'#type' => 'hidden',
'#value' => 'language:' . $manager->getCurrentLanguage()->getId(),
];
$form['f[1]'] = [
'#type' => 'hidden',
'#value' => 'type:Insight',
];
}
There doesn't appear to be any documentation about adding filters this way. But I did find this: NodeSearch::buildSearchUrlQuery. It appears that one should somehow be able to use OR and Negation in this, but I just can't figure it out.
I've tried this:
$form['f[1]'] = [
'#type' => 'hidden',
'#value' => 'type:Insight OR type:Event',
];
This just filters by the last one listed. I also tried this:
$form['f[1]'] = [
'#type' => 'hidden',
'#value' => 'type:Insight OR Event',
];
And this:
$form['f[1]'] = [
'#type' => 'hidden',
'#value' => 'type:["Insight","Event"]',
];
And none of these were working to filter in (or out) multiple content types.
Any help would be greatly appreciated. Or just pointing me to some documentation on using filters this way. Thanks.