2011-06-03 70 views
1

我有一个分类父TID“8”如何让分类儿童ID在Drupal

我需要让所有的孩子TID这个父ID

$tid = 8; 

$children = taxonomy_get_children($tid); 

print_r($children); 

正在此结果

8 

Array 
(
[9] => stdClass Object 
    (
     [tid] => 9 
     [vid] => 3 
     [name] => Domestic 
     [description] => Domestic 
     [weight] => 0 
    ) 

[12] => stdClass Object 
    (
     [tid] => 12 
     [vid] => 3 
     [name] => Economic 
     [description] => Economic 
     [weight] => 1 
    ) 

[11] => stdClass Object 
    (
     [tid] => 11 
     [vid] => 3 
     [name] => International 
     [description] => 
     [weight] => 2 
    ) 

[10] => stdClass Object 
    (
     [tid] => 10 
     [vid] => 3 
     [name] => Social 
     [description] => 
     [weight] => 3 
    ) 

) 

如何只显示此数组中的tid。

回答

4
$children = array_keys(taxonomy_get_children($tid)); 

你会发现它是一个关联数组,其中在对象中的TID相同的数组键 - 只要抓住关键,它等同于对象本身抓住TIDS。