You are here

function search_api_exclude_form_node_form_alter in Search API exclude 7

Same name and namespace in other branches
  1. 8 search_api_exclude.module \search_api_exclude_form_node_form_alter()

Implements hook_form_BASE_FORM_ID_alter() for node_form().

File

./search_api_exclude.module, line 68
Allows users to exclude specific nodes from indexing by Search API.

Code

function search_api_exclude_form_node_form_alter(array &$form, array &$form_state, $form_id) {
  $types = variable_get('search_api_exclude_types', array());
  if (user_access('administer search_api_exclude') && !empty($types[$form['type']['#value']])) {
    $node = $form['#node'];
    $form['search_api_exclude'] = array(
      '#type' => 'fieldset',
      '#title' => t('Search API settings'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#weight' => 20,
      '#group' => 'additional_settings',
    );
    $form['search_api_exclude']['search_api_exclude'] = array(
      '#type' => 'checkbox',
      '#title' => t('Exclude from Search API'),
      '#description' => t('Exclude this node from being indexed in Search API.'),
      '#default_value' => !empty($node->nid) ? (bool) search_api_exclude_get_excluded(array(
        $node->nid,
      )) : FALSE,
      '#weight' => 5,
    );
  }
}