Consulta a Ciudades

mail@pastecode.io avatar
unknown
php
a month ago
575 B
3
Indexable
Never
<?php
public function getOptions($vid, $parent)
  {
    if ($parent === 0) {
      $terms = $this->manager->getStorage('taxonomy_term')->loadTree($vid);
    } else {
      $terms = $this->manager->getStorage('taxonomy_term')->loadTree($vid, $parent, 1, FALSE);
    }

    $options = array();

    foreach ($terms as $term) {
      if ($parent === 0) {
        if (!empty($term->parents[0] === '0')) {
          $options[$term->tid] = $term->name;
        }
      } else {
        $options[$term->tid] = $term->name;
      }
    }
    return $options;
  }
Leave a Comment