tags:

views:

32

answers:

1

Without going through the UI, how would I add an existing CCK field type to an existing content type in Drupal?

I'm imagining I could add the change of configuration straight to the database in an 'install' file, but if not, which hook should I call for this?

+1  A: 

There's no hook that does this, as far as I know.

The least painful way would probably be to use CCK's Content Copy submodule to generate PHP code that represents your field. Then you could feed that PHP code into content_copy_import_form() or copy the code from content_copy_import_form_submit() into a separate utility function. (These are the internal functions that Content Copy uses for it's import/export operations, and weren't really meant to be used this way. So, ready carefully and understand what's going on before you mess around.)

An alternative method that involves installing some new custom modules is at http://neminis.org/blog/drupal/programmatic-cck-content-types-updated/. This might be a more maintainable solution if you find yourself doing it a lot.

anschauung
The content_copy_import_form_submit() is what I need to look at. It's a little more complicated than the answer I was hoping for, but that's not your fault... Thanks!
lazysoundsystem
Yeah, I agree it's a shame there's not an easier way
anschauung

related questions