function active_tags_popular_enable_widget in Active Tags 6.2
Same name and namespace in other branches
- 6 active_tags_popular.module \active_tags_popular_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_popular_enable_widget()
- active_tags_popular_node_form_attach in ./
active_tags_popular.module - Enables Active Tags Popular for core taxonomy tag vocabularies.
File
- ./
active_tags_popular.module, line 15 - Adds popular terms to Active Tags widget
Code
function active_tags_popular_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)) {
$callback = url('taxonomy/active-tags-popular');
drupal_add_js(array(
'active_tags_popular' => $ids,
'active_tags_popular_callback' => $callback,
), 'setting');
drupal_add_js(drupal_get_path('module', 'active_tags_popular') . '/active_tags_popular.js', 'module');
}
}