I have a use case where I want certain Content Types unindexed by default.
I added this piece of code to enable the exclude for indexing based on content type.
function exclude_for_indexing_form_alter(&$form, $form_state, $form_id) {
//TODO: make this available in back-end
$selected_contenttypes = array('medewerkers');
foreach($selected_contenttypes as $ct) {
if(isset($form['nid']) && !is_numeric($form['nid']) && $form_id == $ct.'_node_form') {
$form['#node']->search_api_exclude = 1;
}
}
}
Cheers
Closed: outdated
1.0
Code