Get all node fields?
Can someone suggest a way to get get a list of user-editable* fields in a node of a given content type? I'm trying to write a module which will set field defaults in nodes being created by Feed API -- including fields which do not exist in the feed, hence I need to know what's in the node, not what's in the feed. It also has to be different _per feed_, hence I can't just go by content type -- not that that is any easier. *By user-editable, I mean the actual data fields, not the meta-data fields. I don't want to mess with things like nid, vid, type, uid, status, etc. Rather, just any field which any module (e.g. CCK) might have added to a basic node to create a new content type. Obviously, I can look at the node object, but it's very flat; there's no way to tell user data from meta-data attributes. Calling content_fields() will get me the CCK-added fields, I think (I worry about the date module...). And I can hard-code the basic core node fields, if I have to. But I'd prefer a general solution. Advice? Ideas? Thanks, ..chris
On Sunday 13 September 2009, Chris Johnson wrote:
Can someone suggest a way to get get a list of user-editable* fields in a node of a given content type? [snip] *By user-editable, I mean the actual data fields, not the meta-data fields. I don't want to mess with things like nid, vid, type, uid, status, etc. Rather, just any field which any module (e.g. CCK) might have added to a basic node to create a new content type. [snip]
Advice? Ideas?
I created Field Tool (project/fieldtool) for that sort of "describing field properties" task; for upcoming Drupals, you might want to have a look at fago's patch at http://drupal.org/node/575508. Field Tool is probably still not quite where you need it, but it might be the closest match that you'll probably find. Maybe you want to check out if it can be made to work for your purposes. Wishes, Jakob
I'm not sure if this is what you're looking for, but if you are using CCK, content_fields($field_name = NULL, $content_type_name = NULL) maybe of use to you. On Sep 14, 2009, at 10:34 AM, Jakob Petsovits wrote:
On Sunday 13 September 2009, Chris Johnson wrote:
Can someone suggest a way to get get a list of user-editable* fields in a node of a given content type? [snip] *By user-editable, I mean the actual data fields, not the meta-data fields. I don't want to mess with things like nid, vid, type, uid, status, etc. Rather, just any field which any module (e.g. CCK) might have added to a basic node to create a new content type. [snip]
Advice? Ideas?
I created Field Tool (project/fieldtool) for that sort of "describing field properties" task; for upcoming Drupals, you might want to have a look at fago's patch at http://drupal.org/node/575508.
Field Tool is probably still not quite where you need it, but it might be the closest match that you'll probably find. Maybe you want to check out if it can be made to work for your purposes.
Wishes, Jakob
Probably the closest we have in Drupal 6 would be calling content_fields() and then adding what's returned by hook_content_extra_fields() (see some explanation of this hook at http://www.lullabot.com/articles/great-pretender-making-your-data-act-field). The problem is lots of modules will have added user-editable fields but not implemented this CCK hook. Chris Johnson wrote:
Can someone suggest a way to get get a list of user-editable* fields in a node of a given content type?
On Mon, Sep 14, 2009 at 11:50 AM, Nedjo Rogers <nedjo@islandnet.com> wrote:
Probably the closest we have in Drupal 6 would be calling content_fields() and then adding what's returned by hook_content_extra_fields() (see some explanation of this hook at http://www.lullabot.com/articles/great-pretender-making-your-data-act-field). The problem is lots of modules will have added user-editable fields but not implemented this CCK hook.
Nedjo nails the problem. Not everybody implements the CCK hook, so while I'm currently using the CCK API to get most of the fields, it's not perfect. In an ideal world, the node object would have been designed, rather that grown through accretion. The fields would be organized and we'd have an API to handle this. :-)
participants (4)
-
arthur -
Chris Johnson -
Jakob Petsovits -
Nedjo Rogers