【问题标题】:Drupal 7: Programmatically get the list of tags (taxonomy)Drupal 7:以编程方式获取标签列表(分类)
【发布时间】:2012-04-18 15:26:34
【问题描述】:

我需要以编程方式创建 Drupal 7 网站中使用的标签列表。我正在浏览 api/functions,但找不到像“get_list_of_terms()”这样的东西:-)

我应该如何进行? 谢谢! J.

【问题讨论】:

    标签: drupal tags drupal-7 taxonomy


    【解决方案1】:

    没错。一个稍微完整的例子是(你可以用你自己的词汇 vid 代替):

    if ($terms = taxonomy_get_tree($vocabulary->vid)) {
      foreach ($terms as $term) {
          // Do something with $term->tid or $term->name
      }
    }
    

    【讨论】:

    • 谢谢,对你有很大帮助:)
    【解决方案2】:

    要获取特定词汇表的分类术语列表,您可以使用taxonomy_get_tree

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-04
      相关资源
      最近更新 更多