1

I need the URL alias of the vocabulary, not the term and not the machine name; I need the name that appears to the user.

1 Answer 1

3

You can use taxonomy_vocabulary_load() to obtain the machine name of a specific vid.

Example usage:

$vocabulary = taxonomy_vocabulary_load($vid);
$machine_name = $vocabulary->machine_name;
$name = $vocabulary->name;

Vocabularies aren't exposed to the user like terms are, so they don't really have an url-alias. The name which is presented in the vocabulary list is $name in the above code.

4
  • At least not something that is public. Vocabularies can only "viewed" in the administrative list of terms. The path to that is admin/structure/taxonomy/ ' . $vocabulary->machine_name.
    – Berdir
    May 18, 2011 at 18:58
  • I noticed the admin path, and then attempted to access taxonomy/<machine_name> only to see "page not found". I have wished for such functionality before.
    – jwal
    May 18, 2011 at 19:00
  • Technically vocabularies CAN have a URL aliases if you set one just as I have. I'm creating a custom directory and I need to have links back to the upper category level and in some cases that upper category level is simply the vocabulary URL where it starts. Thanks anyway, I can just use either a vid list and return the URL or just access the database directly from code and get it that way, no biggie.
    – J-Fiz
    May 18, 2011 at 19:16
  • Yes, the URL is above in my comment, and if you pass that through url() or l(), it will automatically use the url alias if there is one. When developing, always work with internal system url's, url() and similar functions will take care of aliasing for you.
    – Berdir
    May 18, 2011 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.