Created
July 6, 2015 17:28
-
-
Save illmatix/f722fe60baa44df3d311 to your computer and use it in GitHub Desktop.
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
| <?php | |
| function ss_menu_location_term_name_load($term_name) { | |
| module_load_include('inc', 'pathauto'); | |
| $vocab = taxonomy_vocabulary_machine_name_load('ss_menu_vocab_categories'); | |
| $vocabTree = taxonomy_get_tree($vocab->vid, 0, NULL, TRUE); | |
| $cleanstrings = array(); | |
| foreach($vocabTree as $term) { | |
| $cleanstring = pathauto_cleanstring($term->name); | |
| $cleanstrings[$cleanstring] = $term->name; | |
| } | |
| $term_name = isset($cleanstrings[$term_name]) ? $cleanstrings[$term_name] : ''; | |
| $term = taxonomy_get_term_by_name($term_name); | |
| // if we don't have the term parent thrown an error | |
| if(empty($term) == TRUE) { | |
| drupal_not_found(); | |
| drupal_exit(); | |
| } | |
| return array_shift($term); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment