You are here

function _create_taxonomy in Event Calendar 7

Function to create a taxonomy and attach fields to it.

See also

taxonomy_vocabulary_save()

1 call to _create_taxonomy()
event_calendar_install in ./event_calendar.install
Implements hook_install().

File

./event_calendar.install, line 104
install file for Event Calendar module.

Code

function _create_taxonomy() {
  $t = get_t();
  $term = new stdClass();
  $term->name = $t('Event Status');
  $term->machine_name = TAXONOMY_TYPE;
  $term->description = $t('Description');
  $term->heirarchy = 1;
  $term->module = 'event_calendar';
  $term->weight = 1;
  taxonomy_vocabulary_save($term);

  // Get the vocabulary ID.
  $vid = db_query('SELECT vid FROM {taxonomy_vocabulary} WHERE machine_name = ' . ':machine_name', array(
    ':machine_name' => TAXONOMY_TYPE,
  ))
    ->fetchField();
  $terms = array(
    array(
      'name' => 'approved',
      'vid' => $vid,
      'weight' => 1,
    ),
    array(
      'name' => 'pending',
      'vid' => $vid,
      'weight' => 2,
    ),
    array(
      'name' => 'denied',
      'vid' => $vid,
      'weight' => 2,
    ),
  );
  foreach ($terms as $term) {
    taxonomy_term_save((object) $term);
  }
}