Hi, i'm just learning about drupal developing and stuf, my issue might be a peace of cake for you, this is what i need: display a list of taxonomy terms given a vocabulary id, like this:

tid -> termname
1 -> term1
2 -> term2
etc

this is what i have:

$terms_for_vocabulary1 = taxonomy_get_tree(1, $parent = 0, $depth = -1, $max_depth = 1);
		
foreach ($terms_for_vocabulary1  as $value) {		
print $terms_for_vocabulary1 [$value][tid] .' -&gt; '. $terms_for_vocabulary1 [$value][name] . '<br />';
}

and this is what i get:
->
->
->
->
->

besides ten of this warnings:

warning: Illegal offset type in ...\www\root\includes\common.inc(1347) : eval()'d code on line 5.

What am i doing wrong?

Thanks in advance

Comments

leanazulyoro’s picture

ups, sorry, this is the code i have:


$terms_for_category = taxonomy_get_tree(1, $parent = 0, $depth = -1, $max_depth = 1);
		
foreach ($terms_for_category as $value){
print $terms_for_category[$value]->tid . ' -&gt;' .$terms_for_category[$value]->name.'<br />';
}

just changed this: $terms_for_category[$value][tid] for this: $terms_for_category[$value]->tid

Miszel’s picture

Try out this:

$terms_for_category = taxonomy_get_tree(1,  0, -1, 1);
foreach ($terms_for_category as $value) {
  print $value->tid . ' -&gt;' . $value->name . '<br />';
}
leanazulyoro’s picture

Status: Active » Fixed

thanks Marcin, thats perfect

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.