Drupal 5: CCK fields in custom content type

孤人 提交于 2019-12-23 20:18:58

问题


I have module that implements custom content type via NodeAPI hooks (hook_insert, hook_update etc). I want to add CCK field to this content type and populate it via hook_nodeapi calls like create or update (to show content nodes in Views).

Problem is, I cannot access CCK fields for this content type. Sure, it's enabled on "Manage Fields" page, but when I load any node of this type with Devel module, I cannot see field attribute (field_flag) in node object. I can see it under "Dev Render" tab as part of "content" attribute, like $node->content['field_flag']['#value'], but if I assign value to $node->field_flag or $node->content['field_flag']['#value'] and call node_save, CCK fields are not saved.

Maybe I must call some other function to save CCK fields? Or what may be wrong with this setup?


回答1:


I believe the field is

$node->field_flag[0]['value']

It's that way in Drupal 6, it doesn't follow the actual name of the field or table field name. The easy way to see what the field is is to fill out a node, then dump it out to see its structure. That will give you the name it is expecting in node_save. I have not used Drupal 5 in a while, but you can't be too far off. You are close.



来源:https://stackoverflow.com/questions/2493461/drupal-5-cck-fields-in-custom-content-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!