Created
December 15, 2011 17:58
-
-
Save matiskay/1482098 to your computer and use it in GitHub Desktop.
Get Vocabulary by name
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 | |
/** | |
* This function will return a vocabulary object which matches the | |
* given name. Will return null if no such vocabulary exists. | |
* | |
* @param String $vocabulary_name | |
* This is the name of the section which is required | |
* @return Object | |
* This is the vocabulary object with the name | |
* or null if no such vocabulary exists | |
*/ | |
function mymodule_get_vocabulary_by_name($vocabulary_name) { | |
$vocabs = taxonomy_get_vocabularies(NULL); | |
foreach ($vocabs as $vocab_object) { | |
if ($vocab_object->name == $vocabulary_name) { | |
return $vocab_object; | |
} | |
} | |
return NULL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment