Attach existing cck field to existing content type in Drupal
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, 开发者_JAVA技巧which hook should I call for this?
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.
精彩评论