如何在drupal中获取分类儿童ID

发布于 2024-11-14 04:43:46 字数 928 浏览 9 评论 0原文

我有一个分类父 tid '8'

我需要获取该父 id 的所有子 tid

$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。

I have a taxonomy parent tid '8'

I need to get all child tid for this parent id

$tid = 8;

$children = taxonomy_get_children($tid);

print_r($children); 

am getting this result

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
    )

 )

how can I display only tid from this array.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

束缚m 2024-11-21 04:43:46
$children = array_keys(taxonomy_get_children($tid));

你会注意到它是一个关联数组,其中对象中的 tid 与数组键相同 - 只需获取键,这相当于从对象本身获取 tid。

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

You will notice it's an associative array where the tid in the object is the same as the array key - just grab the keys, it's equivalent to grabbing the tids from the objects themselves.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文