You are here

function active_tags_enable_widget in Active Tags 6.2

Same name and namespace in other branches
  1. 6 active_tags.module \active_tags_enable_widget()

Attaches active_tags widget to fields.

Parameters

$field_ids: mixed - Either a single field id or an array of ids.

1 call to active_tags_enable_widget()
active_tags_node_form_attach in ./active_tags.module
Enables Active Tags for core taxonomy tag vocabularies.

File

./active_tags.module, line 14
Active Tags widget for free tagging taxonomies

Code

function active_tags_enable_widget($field_ids) {
  static $set_ids = array();

  // Load id into array if a string is passed in.
  if ($field_ids && !is_array($field_ids)) {
    $field_ids = array(
      $field_ids,
    );
  }

  // Ensure we are only adding each setting once.
  // This is important when previewing a node.
  foreach ($field_ids as $id) {
    if (!in_array($id, $set_ids)) {
      $ids[] = $id;
      $set_ids[] = $id;
    }
  }
  if (!empty($ids)) {
    drupal_add_css(drupal_get_path('module', 'active_tags') . '/active_tags.css', 'module');
    drupal_add_js(array(
      'active_tags' => $ids,
    ), 'setting');
    drupal_add_js(drupal_get_path('module', 'active_tags') . '/active_tags.js', 'module', 'footer');
  }
}