forum_enable
- Versions
- 6 – 7
forum_enable()
Code
modules/forum/forum.install, line 22
<?php
function forum_enable() {
if ($vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0))) {
// Save the vocabulary to create the default field instance.
taxonomy_vocabulary_save($vocabulary);
}
else {
// Create the forum vocabulary if it does not exist. Assign the vocabulary
// a low weight so it will appear first in forum topic create and edit
// forms.
$edit = array(
'name' => t('Forums'),
'machine_name' => 'forums',
'description' => t('Forum navigation vocabulary'),
'hierarchy' => 1,
'relations' => 0,
'module' => 'forum',
'weight' => -10,
);
$vocabulary = (object) $edit;
taxonomy_vocabulary_save($vocabulary);
$instance = array(
'field_name' => 'taxonomy_' . $vocabulary->machine_name,
'object_type' => 'node',
'label' => $vocabulary->name,
'bundle' => 'forum',
'widget' => array(
'type' => 'options_select',
),
);
field_create_instance($instance);
variable_set('forum_nav_vocabulary', $vocabulary->vid);
}
}
?>Login or register to post comments 