Skip to main content
Adds example how to get the value of the field.
Source Link
kenorb
  • 14.3k
  • 10
  • 100
  • 170

Here is the D8 example how to access taxonomy terms based on the vocabulary machine name:

$terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree('categories'); foreach ($terms as $term) { //$value = $term->get('field_example')->getValue(); var_dump($term); } 

To load the whole entities, use: loadTree('categories', 0, NULL, TRUE).

Here is the D8 example how to access taxonomy terms based on the vocabulary machine name:

$terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree('categories'); foreach ($terms as $term) { var_dump($term); } 

To load the whole entities, use: loadTree('categories', 0, NULL, TRUE).

Here is the D8 example how to access taxonomy terms based on the vocabulary machine name:

$terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree('categories'); foreach ($terms as $term) { //$value = $term->get('field_example')->getValue(); var_dump($term); } 

To load the whole entities, use: loadTree('categories', 0, NULL, TRUE).

added 219 characters in body
Source Link
kenorb
  • 14.3k
  • 10
  • 100
  • 170

Here is the D8 example how to access taxonomy terms based on the vocabulary machine name:

$terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree('categories'); foreach ($terms as $term) { var_dump($term); } 

To load the whole entities, use: loadTree('categories', 0, NULL, TRUE).

Here is the D8 example how to access taxonomy terms based on the vocabulary machine name:

$terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree('categories'); foreach ($terms as $term) { var_dump($term); } 

Here is the D8 example how to access taxonomy terms based on the vocabulary machine name:

$terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree('categories'); foreach ($terms as $term) { var_dump($term); } 

To load the whole entities, use: loadTree('categories', 0, NULL, TRUE).

Source Link
kenorb
  • 14.3k
  • 10
  • 100
  • 170

Here is the D8 example how to access taxonomy terms based on the vocabulary machine name:

$terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree('categories'); foreach ($terms as $term) { var_dump($term); }