How do I add CCK Field Programmatically?

SomebodySysop - June 7, 2007 - 19:40
Project:Content Construction Kit (CCK)
Version:5.x-1.3
Component:content.module
Category:support request
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

This has probably been covered, I'm sure. And, if so, please direct me to the url.

I would just like to know how to add an existing cck field type (Text) to an existing content type.

I looked at the field_add code, but it seems to be designed for using online forms..

Just trying to create a module that creates a new node type with a couple of custom fields.

Thanks!

#1

yched - June 7, 2007 - 20:32
Status:active» duplicate

I see you found the relevant thread by yourself :-)
http://drupal.org/node/118863

#2

SomebodySysop - June 7, 2007 - 20:36

Yes, but where do I find HOW? This thread says there is a patch which theoretically should allow you to do it, but no where yet have I found any examples on how you actually do it. Can you point me to that?

#3

yched - June 7, 2007 - 20:48

Unfortunately there is not. The patch in the referenced thread is a first attempt / proof of concept, which raises some questions still unsolved, and above all, is not a satisfying future-proof solution, as Eaton states in http://drupal.org/node/118863#comment-249439.

This is mostly due to the way CCK internals are currently built : there is no field CRUD API functions separated from the form / UI incarnation. content_copy.module and the patch you mention "only" are brilliant hacks / workarounds. Writing a proper api has been on the todo for a while, but it's a non-trivial task that nobody (me included) found the proper time to dedicate to.

See also the recent 'Fun CCK idea' discussion on the development mailing list - the archives on list.drupal.org seem to be down ATM, so I can't provide a link.

#4

SomebodySysop - June 7, 2007 - 20:58

Understood. Thanks.

 
 

Drupal is a registered trademark of Dries Buytaert.