I have a use case where I want certain Content Types unindexed by default.

Created on 27 January 2014, about 11 years ago
Updated 20 September 2024, 7 months ago

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

✨ Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium f0ns

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024