【发布时间】:2011-11-26 08:27:27
【问题描述】:
我想生成特定节点类型中所有字段的列表。查看 content_fields 的 API,我尝试了这个:
content_fields(NULL, $nodetype);
不幸的是,这会返回所有定义的字段,而不仅仅是我特定的 $nodetype 中的那些。
有没有办法生成与特定节点类型关联的所有字段的列表?
【问题讨论】:
我想生成特定节点类型中所有字段的列表。查看 content_fields 的 API,我尝试了这个:
content_fields(NULL, $nodetype);
不幸的是,这会返回所有定义的字段,而不仅仅是我特定的 $nodetype 中的那些。
有没有办法生成与特定节点类型关联的所有字段的列表?
【问题讨论】:
目前还没有 CCK 函数可以做到这一点,但您自己的实现会非常容易:
function content_fields_by_type($type_name) {
$type = content_types($type_name);
return isset($type['fields']) ? $type['fields'] : array();
}
【讨论】: