Drupal 9 Loop Term Objects To Retrieve Term Data (id,

[Solved] Drupal 9 Loop Term Objects To Retrieve Term Data (id, | Php Frameworks Drupal - Code Explorer | yomemimo.com
Question : Drupal 9 loop term objects to retrieve term data (id, name, uuid)

Answered by : cheryl-mcnamee

// Get an array of term objects for the given vocabulary
$terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties(['vid' => 'my_vocabulary_machine_name']);
if (!empty($terms)) { foreach ($terms as $term) { //Only return comments that "published" status. if ($term->status->value == 1) { // These assignments show how to // get the term's id, name, and uuid. $terms_array[] = [ 'term_tid' => $term->id(), 'term_name' => $term->name->value, 'term_uuid' => $term->uuid->value, ]; } }
}

Source : | Last Update : Tue, 11 Jan 22

Answers related to Drupal 9 loop term objects to retrieve term data (id, name, uuid)

Code Explorer Popular Question For Php Frameworks Drupal