cck

Programatically creating a CCK field in Drupal 6

I spent some time today trying to figure out how to create a CCK field as part of an hook_update_N function. Unlike previous versions of CCK, in 6 it's very easy to manipulate the fields from code.

The first step is to create the field using CCK's UI. Once you've got the field setup the way you'd like it use PHP's var_export() to dump the contents of the node's field as an array:

var_export(content_fields('field_translator_note', 'feature'));

Moving CCK description field into the node body

Back in Drupal 4.7 if you were using CCK for nodes the node body was left empty. In Drupal 5 CCK nodes now can have a body. I wanted to move data from a field named description into the node body so I came up with the following snippet fit for running in the devel module's execute PHP block.

for you, a photo

nate getting rowdy

ads

User login

Syndicate content