【问题标题】:How to list the fields in a particular node-type?如何列出特定节点类型中的字段?
【发布时间】:2011-11-26 08:27:27
【问题描述】:

我想生成特定节点类型中所有字段的列表。查看 content_fields 的 API,我尝试了这个:

content_fields(NULL, $nodetype);

不幸的是,这会返回所有定义的字段,而不仅仅是我特定的 $nodetype 中的那些。

有没有办法生成与特定节点类型关联的所有字段的列表?

【问题讨论】:

    标签: php drupal drupal-6 cck


    【解决方案1】:

    目前还没有 CCK 函数可以做到这一点,但您自己的实现会非常容易:

    function content_fields_by_type($type_name) {
      $type = content_types($type_name);
      return isset($type['fields']) ? $type['fields'] : array();
    }
    

    【讨论】:

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