Querys a Taxonomia
unknown
php
2 years ago
580 B
5
Indexable
public function getOptions($vid, $parent, bool $full = false) {
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 AND !$full) {
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