Created
May 20, 2015 23:19
-
-
Save Morasta/fd9034dfda5deaa1d50e to your computer and use it in GitHub Desktop.
Drupal 7 - key/value (machine_name/display_name) taxonomy term list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function keyvalue_taxonomy_term_list($vocabMachineName){ | |
$tax = taxonomy_vocabulary_machine_name_load($vocabMachineName); | |
$termTree = taxonomy_get_tree($tax->vid); | |
$terms = array(); | |
foreach ($termTree as $idx => $term) { | |
$terms[str_replace($vocabMachineName.'/', '', drupal_lookup_path('alias', 'taxonomy/term/'.$term->tid, 'und'))] = $term->name; | |
} | |
return $terms; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Returns an array of taxonomy term machine and display names for a given vocabulary machine name structured:
array(machine_name => display_name);