function views_term_hierarchy_weight_field_install in Views Term Hierarchy Weight Field 7
Same name and namespace in other branches
- 8 views_term_hierarchy_weight_field.install \views_term_hierarchy_weight_field_install()
Implements hook_install().
1 call to views_term_hierarchy_weight_field_install()
- views_term_hierarchy_weight_field_update_7005 in ./
views_term_hierarchy_weight_field.install - Implements hook_update_N(). Create missing table fields.
File
- ./
views_term_hierarchy_weight_field.install, line 38
Code
function views_term_hierarchy_weight_field_install() {
$schema = array();
views_term_hierarchy_weight_field_schema_alter($schema);
foreach (array(
'hweight',
'hdepth',
) as $field) {
if (!db_field_exists('taxonomy_term_data', $field)) {
db_add_field('taxonomy_term_data', $field, $schema['taxonomy_term_data']['fields'][$field]);
}
}
$field = 'hweight';
if (!db_field_exists('menu_links', $field)) {
db_add_field('menu_links', $field, $schema['menu_links']['fields'][$field]);
}
if (module_exists('entity_menu_links')) {
if (!db_field_exists('menu_links_revision', $field)) {
db_add_field('menu_links_revision', $field, $schema['menu_links_revision']['fields'][$field]);
}
}
$vocabularies = taxonomy_get_vocabularies();
foreach ($vocabularies as $vid => $vocabulary) {
foreach (taxonomy_get_tree($vid) as $hweight => $term) {
$hdepth = count(taxonomy_get_parents_all($term->tid)) - 1;
views_term_hierarchy_weight_field_update($term->tid, $hweight, $hdepth);
}
}
}