Skip to content

Instantly share code, notes, and snippets.

@zhangtaihao
Created November 9, 2010 01:57
Show Gist options
  • Save zhangtaihao/668604 to your computer and use it in GitHub Desktop.
Save zhangtaihao/668604 to your computer and use it in GitHub Desktop.
Drupal: map content_taxonomy field vocabulary settings to core taxonomy node type configuration
$nodes = array();
foreach (content_fields() as $field_key => $field) {
if (strpos($field['module'], 'content_taxonomy') === 0) {
$type = $field['type_name'];
$nodes[$field['vid']][$field_key] = $type;
}
}
module_load_include('inc', 'taxonomy', 'taxonomy.admin');
foreach ($nodes as $vid => $types) {
$vocabulary = (array) taxonomy_vocabulary_load($vid);
foreach ($types as $type) {
$vocabulary['nodes'][$type] = $type;
}
taxonomy_save_vocabulary($vocabulary);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment