Skip to content

Instantly share code, notes, and snippets.

@illmatix
Created July 6, 2015 17:28
Show Gist options
  • Select an option

  • Save illmatix/f722fe60baa44df3d311 to your computer and use it in GitHub Desktop.

Select an option

Save illmatix/f722fe60baa44df3d311 to your computer and use it in GitHub Desktop.
<?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