function hook_search_admin

Add elements to the search settings form.

Return value

Form array for the Search settings page at admin/config/search/settings.

Related topics

3 functions implement hook_search_admin()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

node_search_admin in drupal/core/modules/node/node.module
Implements hook_search_admin().
search_extra_type_search_admin in drupal/core/modules/search/tests/modules/search_extra_type/search_extra_type.module
Implements hook_search_admin().
theme_node_search_admin in drupal/core/modules/node/node.module
Returns HTML for the content ranking part of the search settings admin page.
1 invocation of hook_search_admin()
SearchSettingsForm::buildForm in drupal/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php
Implements \Drupal\Core\Form\FormInterface::buildForm().

File

drupal/core/modules/search/search.api.php, line 104
Hooks provided by the Search module.

Code

function hook_search_admin() {

  // Output form for defining rank factor weights.
  $form['content_ranking'] = array(
    '#type' => 'details',
    '#title' => t('Content ranking'),
  );
  $form['content_ranking']['#theme'] = 'node_search_admin';
  $form['content_ranking']['#tree'] = TRUE;
  $form['content_ranking']['info'] = array(
    '#value' => '<em>' . t('The following numbers control which properties the content search should favor when ordering the results. Higher numbers mean more influence, zero means the property is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em>',
  );

  // Note: reversed to reflect that higher number = higher ranking.
  $options = drupal_map_assoc(range(0, 10));
  $ranks = config('node.settings')
    ->get('search_rank');
  foreach (module_invoke_all('ranking') as $var => $values) {
    $form['content_ranking']['factors'][$var] = array(
      '#title' => $values['title'],
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => isset($ranks[$var]) ? $ranks[$var] : 0,
    );
  }
  $form['#submit'][] = 'node_search_admin_submit';
  return $form;
}