Skip to content

Instantly share code, notes, and snippets.

@heddn
Created December 20, 2013 14:42
Show Gist options
  • Select an option

  • Save heddn/8055664 to your computer and use it in GitHub Desktop.

Select an option

Save heddn/8055664 to your computer and use it in GitHub Desktop.
/**
* Create a taxonomy term and return the tid.
*/
function asg_estimate_create_taxonomy_term($name, $vid) {
$term = new stdClass();
$term->name = $name;
$term->vid = $vid;
taxonomy_term_save($term);
return $term->tid;
}
/**
* Implements hook_install().
*/
function asg_estimate_install() {
$vocabulary = taxonomy_vocabulary_machine_name_load('status');
$statuses = array(
'Draft',
'Submitted',
'Queried',
'Cancelled',
'Complete',
'Approved',
);
foreach ($statuses as $status) {
asg_estimate_create_taxonomy_term($status, $vocabulary->vid);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment