Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drupal 7: Programmatically get the list of tags (taxonomy)

I need to programmatically create a list of the tags used in a Drupal 7 website. I'm browsing through the api/functions, but can't find something like "get_list_of_terms()" :-)

How should I proceed? Thanks! J.

like image 456
Jem Avatar asked Apr 18 '12 15:04

Jem


2 Answers

Exactly. A slightly more complete example is (you can substitute with your own vocabulary vid):

if ($terms = taxonomy_get_tree($vocabulary->vid)) {
  foreach ($terms as $term) {
      // Do something with $term->tid or $term->name
  }
}
like image 84
Boriana Ditcheva Avatar answered Sep 19 '22 17:09

Boriana Ditcheva


To get a list of taxonomy terms for a particular vocabulary, you could use taxonomy_get_tree

like image 39
nmc Avatar answered Sep 21 '22 17:09

nmc