Consulta a Ciudades

 avatar
unknown
php
a year ago
575 B
6
Indexable
<?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;
  }
Editor is loading...
Leave a Comment