views:

910

answers:

3

The Content Construction Kit (CCK) is one of the most useful Drupal modules. It allows you to easily add custom fields to a content type.

However, these new fields are created through Drupal itself and stored in the database. This means that if you change a CCK field in your development environment you need to manually make the same change in your test and production environments.

Worse, there's no simple way to determine if your environments have gotten out of sync. So if you ever inadvertantly mess up or omit a change as you put it into test or production you may never realise.

I'm looking for a technique that allows me to export CCK field definitions that supports:

  • Importing into new environments (obviously)
  • Creating new fields

Ideally the export would also support:

  • Diffing
  • Modification of existing fields
  • Deletion of existing fields
  • Some kind of conflict resolution in situations where data clashes with field changes

The simpler and more repeatable the solution the better. I would like to avoid custom scripting or GUI automation unless there is a very clean way to do this.

+3  A: 

Are you aware of the Content Copy module that is part of the standard cck package? It offers export/import functionality for fields and whole content types to some extent.

It does not offer diffing by itself, and I'm not sure about how well it does modifications of already existing fields, but it helps a lot for moving new fields and/or content types.

Also, you can save the output of exports from different instances and diff them locally, which gives you a pretty good overview of changes (especially revealing 'out of sync' situations quickly).

After enabling, check the new export and import tabs on top of '/admin/content/types'.

Henrik Opel
+1  A: 

It is not that mature yet but the features module will allow you to do this. It packages up CCK fields (among other things) into drupal modules which you can distribute.

Jeremy French
A: 

I personally use the Node Export module + Node Export File module (included, for CCK /image fields).

The entire node is exported into a textarea, as an associative array. The import form is similar: you paste the node array into a textarea. These processes are implemented as node operations, so they can be done in bulk (on the /admin/content/node page, or in your custom deployment module).

The benefit of this process is that you can modify the node data in transit.

Using a text editor, you can change the content type, title, add/remove/modify fields, whatever you want. Using a text editor with good find/replace, you can mass-edit hundreds of nodes. Since you have text, you can probably do all the things on your requirements list using existing tools or quickie scripts.

threecheeseopera

related questions