问题描述:

Hi

Suppose I have taxonomy "test", and under this taxonomy, I have terms "test2" and "test3". I want to loop all terms under taxonomy "test'. I found a api function "taxonomy_get_children" that can get all children (reference: http://api.drupal.org/api/drupal/modules--taxonomy--taxonomy.module/function/taxonomy_get_children/6), my code didn't works, could someone give me a idea?(I am using Drupal 6)

Thank you

<?php

$a = taxonomy_get_children(1, $vid, 'tid');

print_r($a);

?>

网友答案:

Are you sure your tid = 1? Or is your $vid = 1

tid = term id (the actual term in the vocabulary) vid = vocab id (the vocabulary where the term exists)

Typically, if you know your vocabulary id is 1, youd call it like this:

$a = taxonomy_get_children($tid, 1);
print_r($a);

Or if you don't know the vid, just pass in the $tid

$a = taxonomy_get_children($tid);
print_r($a);
相关阅读:
Top