vocabulary to options


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function vocabulary_to_options($vid) {
  2. $tree = taxonomy_get_tree($vid);
  3. if ($tree) {
  4. foreach ($tree as $term) {
  5. $choice = new stdClass();
  6. $choice->option = array($term->tid => str_repeat('-', $term->depth) . $term->name);
  7. $options[] = $choice;
  8. }
  9. }
  10. return $options;
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.